Class: Async::IO::AddressEndpoint

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/async/io/endpoint.rb

Overview

This class will open and close the socket automatically.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Endpoint

#accept, each, #each, #hostname, parse, ssl, tcp, try_convert, udp, unix

Constructor Details

#initialize(address, **options) ⇒ AddressEndpoint

Returns a new instance of AddressEndpoint.



151
152
153
154
155
156
# File 'lib/async/io/endpoint.rb', line 151

def initialize(address, **options)
	super(**options)
	
	@address = address
	@options = options
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



162
163
164
# File 'lib/async/io/endpoint.rb', line 162

def address
  @address
end

#optionsObject (readonly)

Returns the value of attribute options.



163
164
165
# File 'lib/async/io/endpoint.rb', line 163

def options
  @options
end

Instance Method Details

#bind(&block) ⇒ Object



165
166
167
# File 'lib/async/io/endpoint.rb', line 165

def bind(&block)
	Socket.bind(@address, **@options, &block)
end

#connect(&block) ⇒ Object



169
170
171
# File 'lib/async/io/endpoint.rb', line 169

def connect(&block)
	Socket.connect(@address, **@options, &block)
end

#to_sObject



158
159
160
# File 'lib/async/io/endpoint.rb', line 158

def to_s
	"\#<#{self.class} #{@address.inspect}>"
end