[JDEV] Re: server2client
Christian Ratliff
ratlifc at lily.org
Mon Sep 20 11:21:08 CDT 1999
The character-at-a-time problem is a tough one. I solved it with the
following implementation:
buffer = ""
while ((read() append to buffer) != error)
while (fragment in buffer)
hand fragment to interpreter
remove fragment from buffer
end
end
Essentially, I read data from the socket and append it to a buffer.
Then search the buffer for a full fragment. If I find one remove it from
the buffer and process it as a command. Then try to find another
fragment in the buffer... If there are no more fragments in the buffer,
then try to read() more data from the socket.
christian
More information about the JDev
mailing list