On Sun, 2005-10-30 at 20:51 -0500, Austin Haas wrote:
> 1. How do I detect when the client has closed the connection? If I read
> an EOF? Right now, I am closing as soon as read-char returns the
> specified eof-value, which I defined as the null byte.
You may want to alter your READ-CHAR forms to return NIL instead of
+NULL+ when EOF is encountered. The way you have it now, it mixes
together the two conditions and you can't tell what really occurred--did
you read a +NULL+ or did you encounter EOF? Either that or have READ-
CHAR generate a condition which you can then catch and then close the
stream. Personally, I typically return NIL from READ-* upon EOF.
> 2. What is the best way to read up to the null byte? I'm currently
> reading character by character, but I don't know if I'm doing it the
> safest and most efficient way.
You're probably doing it fine for now. It's tempting to use READ-
SEQUENCE into a large buffer and then scan along, but this doesn't work
with sockets because of the termination semantics of READ-SEQUENCE. It
only returns when it reads every byte in the buffer or it encounters
EOF. Thus there is no way to read a variable-length message from a
I would note that READ-UPTO-NULL will generate a condition if you read
more than 1024 bytes. The SETF will then be trying to insert the
character past the end of the array. You either need to check for this
or read up about VECTOR-PUSH-EXTEND and adjustable arrays.
> 3. Is there any documentation for the arguments to socket-make-stream? I
> couldn't find anything about the buffering keyword.
I don't know, offhand. Worst case, dive into the code. Looks like the
docs say that all the various arguments are passed into SB-SYS:MAKE-FD-
Dave Roberts <ldave@...>