timeout : Java Glossary


Sometimes you are prepared to wait only N seconds for an operation to complete. If it takes longer than that, you want to give up. The length of time you wait is the timeout. You often use these in socket communications. The other end may be down or impossibly sluggish, or the link may not be functioning.

You can use Socket.setSoTimeout to set how long you are prepared for a read to complete. setSoTimeout has no effect on how long you are willing to wait for a write (how long you are willing to wait for the other end to accept data), just on how long you are willing to wait for the other end to produce data.

You can use Socket.setSoLinger to control how long the Socket lingers, (waits to close when there are still unsent data). When you shutdown, the other end should continue to read any buffered data to let the other end close before closing itself.

In other instances you need to roll your own timeouts with a Timer or raw Threads.

This page is posted
on the web at:


Optional Replicator mirror
of mindprod.com
on local hard disk J:

Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Your face IP:[]
You are visitor number