net-receive question

Started by jeremyc, December 06, 2006, 08:46:30 AM

Previous topic - Next topic

jeremyc

I am trying to implement the SCGI protocol. It does something like:



120:SERVER_HOST(char 0)localhost:4000(char 0)QUERY_STRING(char 0)etc....



The 120 is the content length. Then begins key/value pairs separated by the lisp expression (char 0).



So, I do: (net-receive connection 'size 15 ":") which works fine. I then (int size). Then I do (net-receive connection 'key 2048 (char 0)) which only reads 1 character. Again (net-receive connection 'val 2048 (char 0)) which again only reads 1 character.



Am I doing something wrong? I am new to lisp.



Jeremy

Lutz

#1
the wait-string in 'net-receive' cannot contain zero characters. I would try the following:


(net-receive connection 'size 15 ":")

(set 'size (int size))

(net-receive connection 'params size)

; now you have this in params:
 "SERVER_HOST00localhost:400000QUERY_STRING00"

; replace the zeros with "-"

(replace "00" params "-")

(parse params "-") => ("SERVER_HOST" "localhost:4000" "QUERY_STRING" "")


Lutz



ps: please not also the announcement for development version 9.0.6 a short time ago, it was posted at the same time as this thread.

jeremyc

#2
I tried something similar to this, but when doing so the requests per second it could handle dropped dramatically. So far, I began to pursue reading the key/value pair individually hoping to eliminate the slowdown.



Also, on another note, would you recommend using the devel versions of newlisp? I have no problem with that, just curious. I am currently running 9.0 I believe.



Jeremy

jeremyc

#3
Ok, here are the stats:



Only reading the data (no parsing, replacing, etc): 2680.97 rps

Only replacing 00 with (char 1): 1996.01 rps

Replacing and parsing: 1855.95 rps



This is a slow down, but when you do more work slow down appears. I must have been doing something else because I was down in the 150 rps range before.



Jeremy

Lutz

#4
QuoteAlso, on another note, would you recommend using the devel versions of newlisp? I have no problem with that, just curious. I am currently running 9.0 I believe.


The development releases are pretty stable (most of the time). I would look into the change notes if there is anything specific you need, and which bugs have been fixed.



The networking area has not changed except for additional HTTP functionality in the newLISP server mode. Any feature, which is new handle with care ;).



Lutz



ps: just updated the changes notes which did not contain text for versions 9.0.1-4