Skip to content

Instantly share code, notes, and snippets.

@jodosha
Created May 18, 2009 10:02
Show Gist options
  • Save jodosha/113404 to your computer and use it in GitHub Desktop.
Save jodosha/113404 to your computer and use it in GitHub Desktop.
if Config::CONFIG['host'] =~ /mswin/i
def socket_active?
return false if not @sock or @sock.closed?
begin
@sock.write("\0")
Timeout.timeout(0.1){ @sock.read } # TODO make 0.1 configurable
rescue Exception
false
end
end
else
def socket_active?
@sock and not @sock.closed? and @sock.stat.readable?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment