Class: Middleman::PreviewServer::TcpPortProber
- Inherits:
-
Object
- Object
- Middleman::PreviewServer::TcpPortProber
- Defined in:
- lib/middleman-core/preview_server/tcp_port_prober.rb
Overview
Probe for tcp ports
This one first tries try_port
if this is not available use the free
port returned by TCPServer.
Instance Method Summary collapse
-
#port(try_port) ⇒ Integer
Check for port.
Instance Method Details
#port(try_port) ⇒ Integer
Check for port
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/middleman-core/preview_server/tcp_port_prober.rb', line 15 def port(try_port) server = TCPServer.open(try_port) server.close try_port rescue server = TCPServer.open(0) port = server.addr[1] server.close port end |