Class: Server
Instance Method Summary
collapse
Methods inherited from Evented
#callbacks, #emit, #on, #start, #start_threaded, #stop, #streams, #tick
Constructor Details
#initialize(host, port) ⇒ Server
Returns a new instance of Server.
5
6
7
8
9
|
# File 'lib/evented/server.rb', line 5
def initialize(host, port)
super()
@io = TCPServer.new(host, port)
streams << self
end
|
Instance Method Details
#handle_read ⇒ Object
15
16
17
18
19
|
# File 'lib/evented/server.rb', line 15
def handle_read
sock = @io.accept_nonblock
emit(:accept, Stream.new(sock))
rescue IO::WaitReadable
end
|
#handle_write ⇒ Object
21
22
23
|
# File 'lib/evented/server.rb', line 21
def handle_write
end
|
#to_io ⇒ Object
11
12
13
|
# File 'lib/evented/server.rb', line 11
def to_io
@io
end
|