Class: Docker::API::Transport::Tcp
- Defined in:
- lib/docker/api/transport/tcp.rb
Overview
A daemon reached over plain TCP. Unencrypted, so appropriate only on a trusted network or a loopback address.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#host ⇒ String
readonly
The host.
-
#port ⇒ Integer
readonly
The port.
Instance Method Summary collapse
-
#connect ⇒ IO
A connected TCP socket.
- #host_header ⇒ String
-
#initialize(host:, port:, open_timeout: 10) ⇒ Tcp
constructor
A new instance of Tcp.
- #to_s ⇒ String (also: #inspect)
Constructor Details
#initialize(host:, port:, open_timeout: 10) ⇒ Tcp
Returns a new instance of Tcp.
21 22 23 24 25 26 |
# File 'lib/docker/api/transport/tcp.rb', line 21 def initialize(host:, port:, open_timeout: 10) super() @host = host @port = Integer(port) @open_timeout = open_timeout end |
Instance Attribute Details
#host ⇒ String (readonly)
Returns the host.
13 14 15 |
# File 'lib/docker/api/transport/tcp.rb', line 13 def host @host end |
#port ⇒ Integer (readonly)
Returns the port.
16 17 18 |
# File 'lib/docker/api/transport/tcp.rb', line 16 def port @port end |
Instance Method Details
#connect ⇒ IO
Returns a connected TCP socket.
30 31 32 33 34 |
# File 'lib/docker/api/transport/tcp.rb', line 30 def connect dial("tcp://#{host}:#{port}") do Socket.tcp(host, port, connect_timeout: @open_timeout) end end |
#host_header ⇒ String
37 38 39 |
# File 'lib/docker/api/transport/tcp.rb', line 37 def host_header "#{host}:#{port}" end |
#to_s ⇒ String Also known as: inspect
42 43 44 |
# File 'lib/docker/api/transport/tcp.rb', line 42 def to_s "#<Docker::API::Transport::Tcp host=#{host} port=#{port}>" end |