In Java, is there a difference between setting a socket with Socket.setSoLinger(true, 0) and not calling setSoLinger at all? Is there a difference in how the socket is closed?
I have looked through the Java sources, and I don't see anything special around socket closes with regards to soLinger. This leads me to believe this is an OS specific behavior. In my case I am working on Linux.
When a timeout is specified via setSoLinger()
, close()
blocks until the closing hand-shake is completed, or until the specified amount of time passes.
However, close()
provides no indication that the closing handshake failed to complete, even
if the time limit set by setSoLinger()
expires before the closing sequence completes.
In other
words, setSoLinger()
does not provide any additional assurance to the application in current
implementations.
Here's the source of info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With