Last active
October 15, 2015 14:40
-
-
Save film42/75da870f2b06197d76d2 to your computer and use it in GitHub Desktop.
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
require "socket" | |
# Detect if a socket is in CLOSE_WAIT | |
def socket_in_close_wait?(socket) | |
# Will return empty string on EOF (closed socket) | |
socket.recv_nonblock(1, ::Socket::MSG_PEEK) == "" | |
rescue IO::WaitReadable | |
false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment