Class: Thin::Backends::TcpServer

Inherits:
Base
  • Object
show all
Defined in:
lib/thin/backends/tcp_server.rb

Overview

Backend to act as a TCP socket server.

Instance Attribute Summary collapse

Attributes inherited from Base

#maximum_connections, #maximum_persistent_connections, #no_epoll, #persistent_connection_count, #server, #ssl, #ssl_options, #threaded, #timeout

Instance Method Summary collapse

Methods inherited from Base

#close, #config, #connection_finished, #connections_list, #empty?, #running?, #size, #ssl?, #start, #stop, #stop!, #threaded?

Constructor Details

#initialize(host, port) ⇒ TcpServer

Returns a new instance of TcpServer.



8
9
10
11
12
# File 'lib/thin/backends/tcp_server.rb', line 8

def initialize(host, port)
  @host = host
  @port = port
  super()
end

Instance Attribute Details

#hostObject

Address and port on which the server is listening for connections.



6
7
8
# File 'lib/thin/backends/tcp_server.rb', line 6

def host
  @host
end

#portObject

Address and port on which the server is listening for connections.



6
7
8
# File 'lib/thin/backends/tcp_server.rb', line 6

def port
  @port
end

Instance Method Details

#connectObject

Connect the server



15
16
17
# File 'lib/thin/backends/tcp_server.rb', line 15

def connect
  @signature = EventMachine.start_server(@host, @port, Connection, &method(:initialize_connection))
end

#disconnectObject

Stops the server



20
21
22
# File 'lib/thin/backends/tcp_server.rb', line 20

def disconnect
  EventMachine.stop_server(@signature)
end

#to_sObject



24
25
26
# File 'lib/thin/backends/tcp_server.rb', line 24

def to_s
  "#{@host}:#{@port}"
end