public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
macournoyer (author)
Tue Feb 05 20:26:06 -0800 2008
commit  d768ff30186e03a0e4167c48cc9d3c6ba55514d8
tree    137cd68fee7c5757fe28193bbca44d2ae61e451a
parent  6283c1164dffe934e4d84803a1b8201a00e679dd
thin / lib / thin / connectors / tcp_server.rb
100644 29 lines (25 sloc) 0.687 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Thin
  module Connectors
    # Connectior to act as a TCP socket server.
    class TcpServer < Connector
      # Address and port on which the server is listening for connections.
      attr_accessor :host, :port
      
      def initialize(host, port)
        @host = host
        @port = port
        super()
      end
      
      # Connect the server
      def connect
        @signature = EventMachine.start_server(@host, @port, Connection, &method(:initialize_connection))
      end
      
      # Stops the server
      def disconnect
        EventMachine.stop_server(@signature)
      end
            
      def to_s
        "#{@host}:#{@port}"
      end
    end
  end
end