Class: Async::IO::SocketEndpoint
- Defined in:
- lib/async/io/endpoint.rb
Overview
This class doesn’t exert ownership over the specified socket, wraps a native ::IO.
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #bind(&block) ⇒ Object
- #connect(&block) ⇒ Object
-
#initialize(socket) ⇒ SocketEndpoint
constructor
A new instance of SocketEndpoint.
Methods inherited from Endpoint
#accept, #each, each, parse, ssl, tcp, try_convert, udp, unix
Constructor Details
#initialize(socket) ⇒ SocketEndpoint
Returns a new instance of SocketEndpoint.
204 205 206 207 |
# File 'lib/async/io/endpoint.rb', line 204 def initialize(socket) # This socket should already be in the required state. @socket = Async::IO.try_convert(socket) end |
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
209 210 211 |
# File 'lib/async/io/endpoint.rb', line 209 def socket @socket end |
Instance Method Details
#bind(&block) ⇒ Object
211 212 213 214 215 216 217 |
# File 'lib/async/io/endpoint.rb', line 211 def bind(&block) if block_given? yield @socket else return @socket end end |
#connect(&block) ⇒ Object
219 220 221 222 223 224 225 |
# File 'lib/async/io/endpoint.rb', line 219 def connect(&block) if block_given? yield @socket else return @socket end end |