module Endpoint

Nested Classes and Modules

class AddressEndpoint

Represents an endpoint for a specific network address.

class BoundEndpoint

Represents an endpoint that has been bound to one or more sockets.

class Generic

Endpoints represent a way of connecting or binding to an address.

class CompositeEndpoint

A composite endpoint is a collection of endpoints that are used in order.

class ConnectedEndpoint

Represents an endpoint that has been connected to a socket.

class HostEndpoint

Represents an endpoint for a hostname and service that resolves to multiple addresses.

class NamedEndpoints

A named endpoints collection is a hash of endpoints that can be accessed by name.

class SocketEndpoint

This class doesn't exert ownership over the specified socket, wraps a native ::IO.

class SSLEndpoint

Represents an SSL/TLS endpoint that wraps another endpoint.

module TLS
class UNIXEndpoint

This class doesn't exert ownership over the specified unix socket and ensures exclusive access by using flock where possible.

class Wrapper

Represents a wrapper for socket operations that provides scheduling and configuration.

Definitions

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

Create a composite endpoint from multiple endpoints.

Signature

parameter endpoints Array(Generic)

The endpoints to compose.

parameter options Hash

Additional options to pass to the composite endpoint.

returns CompositeEndpoint

A new composite endpoint instance.

Implementation

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

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

Signature

returns HostEndpoint

Implementation

def self.tcp(*arguments, **options)
	arguments[3] = ::Socket::SOCK_STREAM
	
	HostEndpoint.new(arguments, **options)
end

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

Signature

returns HostEndpoint

Implementation

def self.udp(*arguments, **options)
	arguments[3] = ::Socket::SOCK_DGRAM
	
	HostEndpoint.new(arguments, **options)
end

def self.named(**endpoints)

Create a named endpoints collection from keyword arguments.

Example: Create a named endpoints collection

endpoints = IO::Endpoint.named(
	http1: IO::Endpoint.tcp("localhost", 8080),
	http2: IO::Endpoint.tcp("localhost", 8090)
)

Signature

parameter endpoints Hash(Symbol, Generic)

Named endpoints as keyword arguments.

returns NamedEndpoints

A new named endpoints instance.

Implementation

def self.named(**endpoints)
	NamedEndpoints.new(endpoints)
end

def self.socket(socket, **options)

Create a socket endpoint from an existing socket.

Signature

parameter socket Socket

The socket to wrap.

parameter options Hash

Additional options to pass to the socket endpoint.

returns SocketEndpoint

A new socket endpoint instance.

Implementation

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

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

Signature

parameter ssl_context OpenSSL::SSL::SSLContext, nil
parameter tls_configuration TLS::Configuration, nil
parameter hostname String, nil
returns SSLEndpoint

Implementation

def self.ssl(*arguments, ssl_context: nil, tls_configuration: nil, hostname: nil, **options)
	SSLEndpoint.new(self.tcp(*arguments, **options), ssl_context: ssl_context, tls_configuration: tls_configuration, hostname: hostname)
end

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

Signature

parameter path String
returns UNIXEndpoint

Implementation

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

def self.file_descriptor_limit

Get the current file descriptor limit for the process.

Signature

returns Integer

The soft limit for the number of open file descriptors.

Implementation

def self.file_descriptor_limit
	Process.getrlimit(Process::RLIMIT_NOFILE).first
end