SocketChannel.close()
should close the Socket. However, there have been some bugs around this issue (should have been solved a long time ago). http://bugs.sun.com/view_bug.do?bug_id=4960962. Another situation that can cause problems: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6179351
Does SocketChannel.close() close the socket also?
-
30-05-2022 - |
Question
I have a server program that needs to close any connections that remain when the server is shutting down. I know I need to call SocketChannel.close()
. My question is if I also need to close the Socket associated with the SocketChannel
or if SocketChannel.close()
does that automatically.
Solution 2
OTHER TIPS
Of course it closes the socket. What else would it be for? The only exception is when the channel is registered with a Selector, when the actual close is deferred to the next select operation.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow