Java tcp packet stream
Is it possible to read a socket inputstream character by character? ObjectInputStream etc are based on a newline character. I would like to be able to read all the characters as they come in. Is this possible?
I have looked at the pipedInputStream/pipedoutputstream but I don't think that-that is quite what I am looking for (I can't figure out how to make pipedstream work)
Thanks,
John
# 1
> Is it possible to read a socket inputstream character
> by character?
Yes, assuming you mean byte by bye
> ObjectInputStream etc are based on a
> newline character.
No.
> I would like to be able to read
> all the characters as they come in. Is this
> possible?
int b = socket.getInputStream.read();
> I have looked at the
> pipedInputStream/pipedoutputstream but I don't think
> that-that is quite what I am looking for (I can't
> figure out how to make pipedstream work)
This has nothing to do with TCP.
ejpa at 2007-7-7 17:14:01 >

# 2
public static void main(String[] args) {
// TODO code application logic here
try {
ServerSocket s = new ServerSocket(1234);
Socket sock = s.accept();
while(true) {
int b = sock.getInputStream().read();
System.out.println(b);
}
} catch (Exception e) {e.printStackTrace();}
}
the above code still expects an enter to be pressed before b will be displayed. How can I read the stream byte by byte as they come in?
--John
# 8
I completly understand, but how can cisco read in realtime when I hit the ? for example ip ? will automatically display the help screen. That is all I want to do. Is it possible?Thanks for all the quick responses. This is just for a hobby but it's getting fun!--John