D
daniel.w.gelder
Hi, I have a server and an applet that connect. The server uses
SocketChannel and the applet uses plain Socket in a thread. When the
server closes the socket (or if the connection is just broken somehow),
I want the applet to recognize this and react.
I know you can block for a byte from the socket's InputStream, with
read(), and get a -1 to show the socket is closed. The problem is I
don't want the thread to block because I am also sending data to the
server occasionally, so blocking would interfere.
How do you resolve this? I noticed that Socket.getInputStream(new
byte[0]) does not do anything, so that's out.
SocketChannel and the applet uses plain Socket in a thread. When the
server closes the socket (or if the connection is just broken somehow),
I want the applet to recognize this and react.
I know you can block for a byte from the socket's InputStream, with
read(), and get a -1 to show the socket is closed. The problem is I
don't want the thread to block because I am also sending data to the
server occasionally, so blocking would interfere.
How do you resolve this? I noticed that Socket.getInputStream(new
byte[0]) does not do anything, so that's out.