class Async::IO::Endpoint

def accept(&block)

def accept(&block)
	backlog = self.options.fetch(:backlog, Socket::SOMAXCONN)
	
	bind do |server|
		server.listen(backlog)
		server.accept_each(&block)
	end
end

def address

def address
	specification.local_address
end

def bind

def bind
	yield specification
end

def connect

def connect
	yield specification
end

def each(specifications, &block)

Generate a list of endpoints from an array.
def each(specifications, &block)
	return to_enum(:each, specifications) unless block_given?
	
	specifications.each do |specification|
		if specification.is_a? self
			yield specification
		elsif specification.is_a? Array
			yield self.send(*specification)
		elsif specification.is_a? String
			yield self.parse(specification)
		elsif specification.is_a? ::BasicSocket
			yield SocketEndpoint.new(specification)
		elsif specification.is_a? Generic
			yield Endpoint.new(specification)
		else
			raise ArgumentError.new("Not sure how to convert #{specification} to endpoint!")
		end
	end
end

def initialize(specification, **options)

def initialize(specification, **options)
	super(specification, options)
end

def parse(string, **options)

def parse(string, **options)
	uri = URI.parse(string)
	self.send(uri.scheme, uri.host, uri.port, **options)
end

def socket_domain

PF_* eg PF_INET etc, normally identical to AF_* constants.
def socket_domain
	address.afamily
end

def socket_protocol

IPPROTO_TCP, IPPROTO_UDP, IPPROTO_IPX, etc.
def socket_protocol
	address.protocol
end

def socket_type

SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, etc.
def socket_type
	address.socktype
end

def ssl(*args, **options)

def ssl(*args, **options)
	SecureEndpoint.new(Endpoint.tcp(*args, **options), **options)
end

def tcp(*args, **options)

def tcp(*args, **options)
	AddressEndpoint.new(Address.tcp(*args), **options)
end

def to_sockaddr

def to_sockaddr
	address.to_sockaddr
end

def udp(*args, **options)

def udp(*args, **options)
	AddressEndpoint.new(Address.udp(*args), **options)
end

def unix(*args, **options)

def unix(*args, **options)
	AddressEndpoint.new(Address.unix(*args), **options)
end