Class: Riser::TCPSocketAddress
- Inherits:
-
SocketAddress
- Object
- SocketAddress
- Riser::TCPSocketAddress
- Defined in:
- lib/riser/sockaddr.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Attributes inherited from SocketAddress
Instance Method Summary collapse
-
#initialize(host, port, backlog = nil) ⇒ TCPSocketAddress
constructor
A new instance of TCPSocketAddress.
- #open_server ⇒ Object
- #to_address ⇒ Object
- #to_s ⇒ Object
Methods inherited from SocketAddress
#==, #eql?, #hash, parse, #to_option
Constructor Details
#initialize(host, port, backlog = nil) ⇒ TCPSocketAddress
Returns a new instance of TCPSocketAddress.
100 101 102 103 104 |
# File 'lib/riser/sockaddr.rb', line 100 def initialize(host, port, backlog=nil) super(:tcp, backlog) @host = host @port = port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
106 107 108 |
# File 'lib/riser/sockaddr.rb', line 106 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
107 108 109 |
# File 'lib/riser/sockaddr.rb', line 107 def port @port end |
Instance Method Details
#open_server ⇒ Object
121 122 123 |
# File 'lib/riser/sockaddr.rb', line 121 def open_server TCPServer.new(@host, @port) end |
#to_address ⇒ Object
109 110 111 |
# File 'lib/riser/sockaddr.rb', line 109 def to_address super << @host << @port end |
#to_s ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/riser/sockaddr.rb', line 113 def to_s if (@host.include? ':') then "tcp://[#{host}]:#{port}" else "tcp://#{host}:#{port}" end end |