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

Java socket not throwing exceptions on a dead socket??  RSS feed

 
Yar lag
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a simple client server architecture between our mobile device and our server both written in Java. An extremely simple ServerSocket and Socket implementation. However one problem is that when the client terminates abruptly (without closing the socket properly) the server does not know that it is disconnected. Furthermore, the server can continue to write to this socket without getting any exceptions. Why?

According to documentation Java sockets should throw exceptions if you try to write to a socket that is not reachable on the other end!
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the route from your server to your mobile device? Is there some intermediate proxy that could be staying alive even though the complete route is broken?
You may have to add in a "heartbeat" message that does a round trip from server to client and back to make sure the route is intact.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!