What does setSoTimeout ( int timeout ) in Socket class do?
807598Nov 3 2006 — edited Jan 4 2007In the API, this method is describe as:
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. With this option set to a non-zero timeout, a read() call on the InputStream associated with this Socket will block for only this amount of time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the Socket is still valid. The option must be enabled prior to entering the blocking operation to have effect. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout.
I have problem understanding it. It say that the Socket will block for the amount of time set. What does 'block' means? Does it mean that the socket waits for the predefined time to receive data packet? Or just wait to receive data packet? Or both? Or I've got it wrong altogether?
Sorry but as you can see, I'm still clueless about many things regarding Java. Thank you for your time and patience.
Message was edited by:
Toc