Class: Bane::Behaviors::Responders::NeverRespond

Inherits:
Object
  • Object
show all
Defined in:
lib/bane/behaviors/responders/never_respond.rb

Overview

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

Constant Summary collapse

READ_TIMEOUT_IN_SECONDS =
2
MAXIMUM_BYTES_TO_READ =
4096

Instance Method Summary collapse

Instance Method Details

#serve(io) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bane/behaviors/responders/never_respond.rb', line 11

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