Class: Async::IO::AddressEndpoint
- Defined in:
- lib/async/io/address_endpoint.rb
Overview
This class will open and close the socket automatically.
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#bind {|Socket| ... } ⇒ Socket
Bind a socket to the given address.
-
#connect(&block) ⇒ Socket
Connects a socket to the given address.
-
#initialize(address, **options) ⇒ AddressEndpoint
constructor
A new instance of AddressEndpoint.
- #to_s ⇒ Object
Methods inherited from Endpoint
#accept, each, #each, #hostname, parse, #reuse_port, socket, ssl, tcp, #timeout, try_convert, udp, unix
Constructor Details
#initialize(address, **options) ⇒ AddressEndpoint
Returns a new instance of AddressEndpoint.
27 28 29 30 31 32 |
# File 'lib/async/io/address_endpoint.rb', line 27 def initialize(address, **) super(**) @address = address @options = end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
38 39 40 |
# File 'lib/async/io/address_endpoint.rb', line 38 def address @address end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
39 40 41 |
# File 'lib/async/io/address_endpoint.rb', line 39 def @options end |
Instance Method Details
#bind {|Socket| ... } ⇒ Socket
Bind a socket to the given address. If a block is given, the socket will be automatically closed when the block exits.
44 45 46 |
# File 'lib/async/io/address_endpoint.rb', line 44 def bind(&block) Socket.bind(@address, **@options, &block) end |
#connect(&block) ⇒ Socket
Connects a socket to the given address. If a block is given, the socket will be automatically closed when the block exits.
50 51 52 |
# File 'lib/async/io/address_endpoint.rb', line 50 def connect(&block) Socket.connect(@address, **@options, &block) end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/async/io/address_endpoint.rb', line 34 def to_s "\#<#{self.class} #{@address.inspect}>" end |