Class: Celluloid::IO::TCPServer

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/celluloid/io/tcp_server.rb

Overview

TCPServer with combined blocking and evented support

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, port) ⇒ TCPServer

Returns a new instance of TCPServer.



10
11
12
# File 'lib/celluloid/io/tcp_server.rb', line 10

def initialize(hostname, port)
  @server = ::TCPServer.new(hostname, port)
end

Class Method Details

.from_ruby_server(ruby_server) ⇒ Object

Convert a Ruby TCPServer into a Celluloid::IO::TCPServer



28
29
30
31
32
# File 'lib/celluloid/io/tcp_server.rb', line 28

def self.from_ruby_server(ruby_server)
  server = allocate
  server.instance_variable_set(:@server, ruby_server)
  server
end

Instance Method Details

#acceptObject



14
15
16
17
# File 'lib/celluloid/io/tcp_server.rb', line 14

def accept
  Celluloid::IO.wait_readable(@server)
  accept_nonblock
end

#accept_nonblockObject



19
20
21
# File 'lib/celluloid/io/tcp_server.rb', line 19

def accept_nonblock
  Celluloid::IO::TCPSocket.new(@server.accept_nonblock)
end

#to_ioObject



23
24
25
# File 'lib/celluloid/io/tcp_server.rb', line 23

def to_io
  @server
end