[3246] in java-interest
Reading a string from a socket -- There must be a better way
daemon@ATHENA.MIT.EDU (Mike Afergan)
Sat Nov 4 15:05:33 1995
Date: Sat, 4 Nov 95 13:26:17 EST
To: java-interest@java.sun.com
From: Mike Afergan <mikea@abba.ai.mit.edu>
I am receiving information over a simple socket. To ensure coherence, each
command is seperated by a null character. The standard syntax that I have
found for reading from a socket is:
n = mc.serverInput.read(buf, 0, buf.length)
However, this seems as if it will read all information sitting in the
stream. Do I have to parse the resuling buffer? What if the buffer contains
half of a command?
While these problems are all managable, I'm sure there is a better way.
What I'd like to do is read until a null character. Parse that command.
Read until the next null character (or wait until the next command), etc.
Any and all suggestions would be greatly appreciated.
Thanks,
-- Mike
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com