Skip to content

Instantly share code, notes, and snippets.

@film42
Last active October 15, 2015 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save film42/75da870f2b06197d76d2 to your computer and use it in GitHub Desktop.
Save film42/75da870f2b06197d76d2 to your computer and use it in GitHub Desktop.
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