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.
133 134 135 136 137 |
# File 'lib/riser/sockaddr.rb', line 133 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.
139 140 141 |
# File 'lib/riser/sockaddr.rb', line 139 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
140 141 142 |
# File 'lib/riser/sockaddr.rb', line 140 def port @port end |
Instance Method Details
#open_server ⇒ Object
154 155 156 |
# File 'lib/riser/sockaddr.rb', line 154 def open_server TCPServer.new(@host, @port) end |
#to_address ⇒ Object
142 143 144 |
# File 'lib/riser/sockaddr.rb', line 142 def to_address super << @host << @port end |
#to_s ⇒ Object
146 147 148 149 150 151 152 |
# File 'lib/riser/sockaddr.rb', line 146 def to_s if (@host.include? ':') then "tcp://[#{host}]:#{port}" else "tcp://#{host}:#{port}" end end |