Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Beginner
Nov 5, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Unexpected Socket Close

How do you determine when a client has closed its socket, so that a server can cease to wait for messages from that client?

When a socket endpoint closes its socket, a read on the InputStream at the other end will return -1, indicating end of file. If the process crashes, the same will happen because the operating system will close the socket when the process dies.

However, if the host that the process is running on crashes, there is no way to detect the endpoint termination. With native system programming, it is possible to set the SO_KEEPALIVE socket option to test the integrity of a connection on a more frequent basis than the default 2 hours. Java does not allow you to do this, and instead relies on the system default.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date