Class: RightSpeed::Listener::SimpleListener

Inherits:
Object
  • Object
show all
Defined in:
lib/right_speed/listener.rb

Direct Known Subclasses

RoundRobinListener

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, backlog) ⇒ SimpleListener

Returns a new instance of SimpleListener.



21
22
23
24
25
26
# File 'lib/right_speed/listener.rb', line 21

def initialize(host, port, backlog)
  @host = host
  @port = port
  @backlog = backlog
  @sock = nil
end

Instance Attribute Details

#sockObject (readonly)

Returns the value of attribute sock.



19
20
21
# File 'lib/right_speed/listener.rb', line 19

def sock
  @sock
end

Instance Method Details

#runObject



28
29
30
31
32
33
# File 'lib/right_speed/listener.rb', line 28

def run
  @running = true
  @sock = TCPServer.open(@host, @port)
  @sock.listen(@backlog) if @backlog
  @sock
end

#stopObject



39
40
41
42
43
44
# File 'lib/right_speed/listener.rb', line 39

def stop
  @running = false
  if @sock
    @sock.close rescue nil
  end
end

#waitObject



35
36
37
# File 'lib/right_speed/listener.rb', line 35

def wait
  # do nothing
end