Class: Thin::Backends::TcpServer
- Inherits:
-
Base
- Object
- Base
- Thin::Backends::TcpServer
show all
- Defined in:
- lib/thin/backends/tcp_server.rb
Overview
Backend to act as a TCP socket server.
Instance Attribute Summary
Attributes inherited from Base
#maximum_connections, #maximum_persistent_connections, #no_epoll, #persistent_connection_count, #server, #threaded, #timeout
Instance Method Summary
collapse
Methods inherited from Base
#close, #config, #connection_finished, #empty?, #size, #threaded?
Constructor Details
#initialize(host, port, options = {}) ⇒ TcpServer
Returns a new instance of TcpServer.
12
13
14
15
16
|
# File 'lib/thin/backends/tcp_server.rb', line 12
def initialize(host, port, options={})
@host = host
@port = port.to_i
@timeout = 30
end
|
Instance Method Details
#fibered? ⇒ Boolean
Allow using fibers in the backend.
10
|
# File 'lib/thin/backends/tcp_server.rb', line 10
def fibered?; true; end
|
#maxfds ⇒ Object
49
|
# File 'lib/thin/backends/tcp_server.rb', line 49
def maxfds;raise "not implemented";end
|
#maxfds=(maxfds) ⇒ Object
47
|
# File 'lib/thin/backends/tcp_server.rb', line 47
def maxfds=(maxfds);raise "not implemented";end
|
#running? ⇒ Boolean
53
|
# File 'lib/thin/backends/tcp_server.rb', line 53
def running?;@reactor.running?;end
|
#start ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/thin/backends/tcp_server.rb', line 18
def start
@reactor = NB.reactor
@server_socket = TCPServer.new(@host, @port)
@server_socket.listen(511)
@reactor.attach(:read, @server_socket) do |server, reactor|
begin
loop do
connection = accept_connection
end
rescue Errno::EWOULDBLOCK, Errno::EAGAIN, Errno::EINTR
rescue Exception => e
end
end
loop do
begin
@reactor.run
break unless @reactor.running?
rescue Exception => e
end
end
@server_socket.close
end
|
#stop ⇒ Object
Also known as:
stop!
41
|
# File 'lib/thin/backends/tcp_server.rb', line 41
def stop;@reactor.stop;end
|
#to_s ⇒ Object
51
|
# File 'lib/thin/backends/tcp_server.rb', line 51
def to_s;"#{@host}:#{@port} (NeverBlock)";end
|
#trace=(trace) ⇒ Object
45
|
# File 'lib/thin/backends/tcp_server.rb', line 45
def trace=(trace);@trace = trace;end
|