Last active
August 29, 2015 14:18
-
-
Save bararchy/5821d4227c95cb865872 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def self.read_for_tcp_proxy(socket) | |
data = socket.read_nonblock(16_384) | |
while socket.pending > 0 | |
data += socket.read_nonblock(16_384) | |
end | |
data | |
rescue IO::WaitReadable | |
IO.select([socket]) | |
retry | |
rescue IO::WaitWritable | |
IO.select(nil, [socket]) | |
retry | |
rescue EOFError => e | |
return e | |
rescue OpenSSL::SSL::SSLError => e | |
if defined? data | |
return data | |
else | |
return e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment