M
Mark McKay
I'm working with sockets on a server/client, and am running into
problems with sending messages back and forth.
I need to send small, unusual sized packets on occassion from the
client which need to go to the server immediately, so I need to call
flush() on my output stream after every message to make sure that it's
on it's way. My server is currently designed to wait for a message,
read it's header, read the message body, send it off for processing
and then wait for the next message. Unfortunately, now having added
the call to flush(), my server now gets an EOFException when it tries
it's next read.
I was hoping this read would block waiting for the next byte of the
header rather than throwing an error. I'm having a hard time trying
to figure out a way to distinguish a socket that has been remotely
closed from a socket which has simply sent a compelete message and not
sent the next yet. Before I was flushing, my reads would block and I
could simply assume that any socket error indicated a closed
connection. Currently the two cases are indistinguishable.
Mark McKay
problems with sending messages back and forth.
I need to send small, unusual sized packets on occassion from the
client which need to go to the server immediately, so I need to call
flush() on my output stream after every message to make sure that it's
on it's way. My server is currently designed to wait for a message,
read it's header, read the message body, send it off for processing
and then wait for the next message. Unfortunately, now having added
the call to flush(), my server now gets an EOFException when it tries
it's next read.
I was hoping this read would block waiting for the next byte of the
header rather than throwing an error. I'm having a hard time trying
to figure out a way to distinguish a socket that has been remotely
closed from a socket which has simply sent a compelete message and not
sent the next yet. Before I was flushing, my reads would block and I
could simply assume that any socket error indicated a closed
connection. Currently the two cases are indistinguishable.
Mark McKay