class Bane::Behaviors::Responders::NeverRespond

Accepts a connection and never sends a byte of data. The connection is left open indefinitely.

Constants

MAXIMUM_BYTES_TO_READ
READ_TIMEOUT_IN_SECONDS

Public Instance Methods

serve(io) click to toggle source
# File lib/bane/behaviors/responders/never_respond.rb, line 13
def serve(io)
  loop do
    begin
      io.read_nonblock(MAXIMUM_BYTES_TO_READ)
    rescue Errno::EAGAIN
      IO.select([io], nil, nil, READ_TIMEOUT_IN_SECONDS)
      retry # Ignore the result of IO select since we retry reads regardless of if there's data to be read or not
    rescue EOFError
      break
    end
  end
end