| Author |
Java socket not throwing exceptions on a dead socket??
|
Yar lag
Greenhorn
Joined: Apr 14, 2009
Posts: 10
|
|
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
Joined: Oct 29, 2001
Posts: 8265
|
|
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.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
 |
|
|
subject: Java socket not throwing exceptions on a dead socket??
|
|
|