This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

client doesn't detect server drop  RSS feed

 
N Goldsmith
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My client waits at the select cmd for any data sent to it via the server. The server can drop off unexpectedly and my client should detect this and attempt a reconnect, but it never detects the server is dead. Why doesn't this disconnect trigger an exception? Does it have anything to do with using non-blocking IO?

My client will just sit at the select forever when the server socket is closed and subsequently the thread running the server is killed. If I happen to close the
DataOutputStream output
then, my client will be triggered that a new read has come in and he will attempt to read from the socket, but will get back a read count of -1. I don't know how he is able to read from a socket that has been shutdown without an I/O exception being thrown:

I stop the server like this and directly after this thread dies:


This is the code for the client. He just sits at the select (which is configured for SelectionKey.OP_READ ), but never detects that the server has dropped. When I close down output, he gets a read cmd and attempts to read from the socket.

Client is configured this way.



Main processing loops


[ December 16, 2004: Message edited by: N Goldsmith ]

[ December 16, 2004: Message edited by: N Goldsmith ]

[ December 16, 2004: Message edited by: N Goldsmith ]

[ December 16, 2004: Message edited by: N Goldsmith ]
[ December 16, 2004: Message edited by: N Goldsmith ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!