class Async::IO::Endpoint

def self.composite(*endpoints, **options)

def self.composite(*endpoints, **options)
	CompositeEndpoint.new(endpoints, **options)
end

def self.each(specifications, &block)

Generate a list of endpoints from an array.
def self.each(specifications, &block)
	return to_enum(:each, specifications) unless block_given?
	
	specifications.each do |specification|
		yield try_convert(specification)
	end
end

def self.parse(string, **options)

Other tags:
    See: Endpoint.unix - unix - invoked when parsing a URL with the unix scheme: "unix://127.0.0.1"
    See: Endpoint.udp - udp - invoked when parsing a URL with the udp scheme: "udp://127.0.0.1"
    See: Endpoint.tcp - tcp - invoked when parsing a URL with the tcp scheme: "tcp://127.0.0.1"
    See: Endpoint.ssl - ssl - invoked when parsing a URL with the ssl scheme "ssl://127.0.0.1"

Parameters:
  • options () -- keyword arguments passed through to {#initialize}
  • string (String) -- URI as string. Scheme will decide implementation used.
def self.parse(string, **options)
	uri = URI.parse(string)
	
	self.public_send(uri.scheme, uri.host, uri.port, **options)
end

def self.socket(socket, **options)

def self.socket(socket, **options)
	SocketEndpoint.new(socket, **options)
end

def self.ssl(*args, ssl_context: nil, hostname: nil, **options)

Returns:
  • (SSLEndpoint) -

Parameters:
  • options () -- keyword arguments passed through to {Endpoint.tcp}
  • hostname (String, nil) --
  • ssl_context (OpenSSL::SSL::SSLContext, nil) --
  • args () --
def self.ssl(*args, ssl_context: nil, hostname: nil, **options)
	SSLEndpoint.new(self.tcp(*args, **options), ssl_context: ssl_context, hostname: hostname)
end

def self.tcp(*args, **options)

Returns:
  • (HostEndpoint) -

Parameters:
  • options () -- keyword arguments passed on to {HostEndpoint#initialize}
  • args () -- nodename, service, family, socktype, protocol, flags. `socktype` will be set to Socket::SOCK_STREAM.
def self.tcp(*args, **options)
	args[3] = ::Socket::SOCK_STREAM
	
	HostEndpoint.new(args, **options)
end

def self.try_convert(specification)

def self.try_convert(specification)
	if specification.is_a? self
		specification
	elsif specification.is_a? Array
		self.send(*specification)
	elsif specification.is_a? String
		self.parse(specification)
	elsif specification.is_a? ::BasicSocket
		self.socket(specification)
	elsif specification.is_a? Generic
		self.new(specification)
	else
		raise ArgumentError.new("Not sure how to convert #{specification} to endpoint!")
	end
end

def self.udp(*args, **options)

Returns:
  • (HostEndpoint) -

Parameters:
  • options () -- keyword arguments passed on to {HostEndpoint#initialize}
  • args () -- nodename, service, family, socktype, protocol, flags. `socktype` will be set to Socket::SOCK_DGRAM.
def self.udp(*args, **options)
	args[3] = ::Socket::SOCK_DGRAM
	
	HostEndpoint.new(args, **options)
end

def self.unix(path = "", type = ::Socket::SOCK_STREAM, **options)

Returns:
  • (UNIXEndpoint) -

Parameters:
  • options () -- keyword arguments passed through to {UNIXEndpoint#initialize}
  • type () -- Socket type
  • path (String) --
def self.unix(path = "", type = ::Socket::SOCK_STREAM, **options)
	UNIXEndpoint.new(path, type, **options)
end

def accept(backlog = Socket::SOMAXCONN, &block)

Parameters:
  • backlog (Integer) -- the number of connections to listen for.
def accept(backlog = Socket::SOMAXCONN, &block)
	bind do |server|
		server.listen(backlog)
		
		server.accept_each(&block)
	end
end

def bound(**options)

def bound(**options)
	SharedEndpoint.bound(self, **options)
end

def connected(**options)

def connected(**options)
	SharedEndpoint.connected(self, **options)
end

def each

Other tags:
    Yield: - Enumerate all discrete paths as endpoints.
def each
	return to_enum unless block_given?
	
	yield self
end

def hostname

Returns:
  • (String) - The hostname of the bound socket.
def hostname
	@options[:hostname]
end

def initialize(**options)

def initialize(**options)
	@options = options.freeze
end

def linger

Returns:
  • (Integer, nil) - The value for SO_LINGER.
def linger
	@options[:linger]
end

def local_address

Returns:
  • (Address) - the address to bind to before connecting.
def local_address
	@options[:local_address]
end

def reuse_address

Returns:
  • (Boolean) - The value for `SO_REUSEADDR`.
def reuse_address
	@options[:reuse_address]
end

def reuse_port

Returns:
  • (Boolean, nil) - The value for `SO_REUSEPORT`.
def reuse_port
	@options[:reuse_port]
end

def timeout

Returns:
  • (Numeric) - The default timeout for socket operations.
def timeout
	@options[:timeout]
end

def with(**options)

def with(**options)
	dup = self.dup
	
	dup.options = @options.merge(options)
	
	return dup
end