Skip to content

Commit

Permalink
Use the correct port when 0 is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
meschbach committed Feb 2, 2016
1 parent 706642b commit 7bb1c28
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/thin/backends/tcp_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@ module Backends
class TcpServer < Base
# 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))
binary_name = EventMachine.get_sockname( @signature )
port_name = Socket.unpack_sockaddr_in( binary_name )
@port = port_name[0]
@host = port_name[1]
@signature
end

# Stops the server
def disconnect
EventMachine.stop_server(@signature)
end

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

0 comments on commit 7bb1c28

Please sign in to comment.