aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes Java socket not throwing exceptions on a dead socket?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Java socket not throwing exceptions on a dead socket??" Watch "Java socket not throwing exceptions on a dead socket??" New topic
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]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Java socket not throwing exceptions on a dead socket??
 
Similar Threads
Opening a socket connection on client m/c
how do i capture screenshot via network in java swing
access to secure FTP server urgent
read() and write() method of socket channel did not work fine for huge data
Opening a socket connection on client machine