ServerSocket doesn't 'realize' if a Socket disconnect.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Christian_Christian
Posted On:   Wednesday, January 17, 2007 11:24 PM

I wrote a simple server program using ServerSocket , and a client program using Socket. In server, I stored Socket from client to a Collection. Problem is, when I check content of Collection in server program, I can't correctly tell if a Socket is already disconnected, even if in client program, following methods is executed. ... socketInClientProgram.shutdownOutput(); socketInClientProgram.getOutputStream().close(); socketInClientProgram.shutdownInput(); socketInClientProgram.getInputStream().close(); socketInClientProgram.close(); ... in server, still, socketInServerProgram.isInputShutdown() return false; socketInServerProgram.isOutputShutdown() re   More>>

I wrote a simple server program using ServerSocket , and a client program using Socket.

In server, I stored Socket from client to a Collection.
Problem is, when I check content of Collection in server program, I can't correctly tell if a Socket is already disconnected, even if in client program, following methods is executed.

			
...
socketInClientProgram.shutdownOutput();
socketInClientProgram.getOutputStream().close();
socketInClientProgram.shutdownInput();
socketInClientProgram.getInputStream().close();
socketInClientProgram.close();
...
in server, still,
socketInServerProgram.isInputShutdown() return false;
socketInServerProgram.isOutputShutdown() return false;
socketInServerProgram.isClosed() return false;
...

Right now, the only solution came to my mind is
			
socketInServerProgram.sendUrgentData(0);

then I can receive a SocketException, problem is
I don't understand the effect of this sendUrgentData() method to my protocol.

My friend created a similar simple program in Delphi, it's ServerSocket received event, when Socket in client call socket.close()

Ever experienced this 'phenomenon' ?

Thank you for reading this posting.    <<Less
About | Sitemap | Contact