class TLSChecker::LineOrientedSocket

Constants

TIMEOUT

Public Instance Methods

gets() click to toggle source
# File lib/tls-checker/line_oriented_socket.rb, line 13
def gets
  line = ''

  line += timed_getbyte until line.end_with?("\r\n")

  line
end
gets_until_match(pattern) click to toggle source
# File lib/tls-checker/line_oriented_socket.rb, line 21
def gets_until_match(pattern)
  loop do
    line = gets
    break if line.match(pattern)
  end
end
puts(data) click to toggle source
# File lib/tls-checker/line_oriented_socket.rb, line 28
def puts(data)
  send("#{data}\r\n", 0)
end

Private Instance Methods

timed_getbyte() click to toggle source
# File lib/tls-checker/line_oriented_socket.rb, line 36
def timed_getbyte
  recv_nonblock(1)
rescue IO::EAGAINWaitReadable
  if IO.select([self], nil, nil, 10)
    recv_nonblock(1)
  else
    raise SocketRecvTimeout
  end
end