Module: GDKBox::Ports
- Defined in:
- lib/gdkbox/ports.rb
Overview
Answers whether a host port is actually usable.
gdkbox's metadata store only knows about ports gdkbox itself allocated; anything else on the machine — typically a locally running GDK on 2222 and 3000 — is invisible to it. Binding is the authoritative test: gdkbox publishes container ports on 127.0.0.1, so try to bind exactly there.
Class Method Summary collapse
-
.bound?(port) ⇒ Boolean
True when something on the host already holds the port (or the bind is not permitted, which is just as unusable for publishing).
Class Method Details
.bound?(port) ⇒ Boolean
True when something on the host already holds the port (or the bind is not permitted, which is just as unusable for publishing).
17 18 19 20 21 22 |
# File 'lib/gdkbox/ports.rb', line 17 def bound?(port) TCPServer.new("127.0.0.1", port).close false rescue SystemCallError true end |