Created
January 17, 2011 23:13
-
-
Save ar/783675 to your computer and use it in GitHub Desktop.
BaseChannel.socketClose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void closeSocket() throws IOException { | |
Socket s = null; | |
synchronized (this) { | |
if (socket != null) { | |
s = socket; // we don't want more than one thread | |
socket = null; // attempting to close the socket | |
} | |
} | |
if (s != null) { | |
try { | |
s.setSoLinger (true, 5); | |
s.shutdownOutput(); // This will force a TCP FIN to be sent. | |
} catch (SocketException e) { | |
// safe to ignore - can be closed already | |
// e.printStackTrace(); | |
} | |
s.close (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment