Skip to content

Instantly share code, notes, and snippets.

@toreriklinnerud
Created October 5, 2011 14:02
Show Gist options
  • Save toreriklinnerud/1264493 to your computer and use it in GitHub Desktop.
Save toreriklinnerud/1264493 to your computer and use it in GitHub Desktop.
begin
loop do
puts "in loop"
if o = IO.select([input, ssl_socket].compact, nil, nil, activity_timeout)
puts "in select if"
if (input && (o.first.first == input))
puts "in if"
data = input.readpartial(10000)
puts "read partial"
ssl_socket.write(data)
puts "wrote"
ssl_socket.flush
puts "flushed"
elsif (o.first.first == ssl_socket)
puts "in else"
data = ssl_socket.readpartial(10000)
puts "read partial"
output.write(data)
puts "wrote"
end
else
raise(Timeout::Error.new)
end
end
rescue EOFError, Errno::EIO =>e
puts "Rescuing from error: #{e.inspect}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment