class Thin::Backends::TcpServer
Backend to act as a TCP socket server.
Attributes
host[RW]
Address and port on which the server is listening for connections.
port[RW]
Address and port on which the server is listening for connections.
Public Class Methods
new(host, port)
click to toggle source
Calls superclass method
Thin::Backends::Base::new
# File lib/thin/backends/tcp_server.rb, line 8 def initialize(host, port) @host = host @port = port super() end
Public Instance Methods
connect()
click to toggle source
Connect the server
# File lib/thin/backends/tcp_server.rb, line 15 def connect @signature = EventMachine.start_server(@host, @port, Connection, &method(:initialize_connection)) binary_name = EventMachine.get_sockname( @signature ) port_name = Socket.unpack_sockaddr_in( binary_name ) @port = port_name[0] @host = port_name[1] @signature end
disconnect()
click to toggle source
Stops the server
# File lib/thin/backends/tcp_server.rb, line 25 def disconnect EventMachine.stop_server(@signature) end
to_s()
click to toggle source
# File lib/thin/backends/tcp_server.rb, line 29 def to_s "#{@host}:#{@port}" end