class IO::Endpoint::ConnectedEndpoint

def self.connected(endpoint, close_on_exec: false)

def self.connected(endpoint, close_on_exec: false)
	socket = endpoint.connect
	
	socket.close_on_exec = close_on_exec
	
	return self.new(endpoint, socket, **endpoint.options)
end

def close

def close
	if @socket
		@socket.close
		@socket = nil
	end
end

def connect(wrapper = self.wrapper, &block)

def connect(wrapper = self.wrapper, &block)
	if block_given?
		yield @socket
	else
		return @socket.dup
	end
end

def initialize(endpoint, socket, **options)

def initialize(endpoint, socket, **options)
	super(**options)
	
	@endpoint = endpoint
	@socket = socket
end

def inspect

def inspect
	"\#<#{self.class} #{@socket} connected for #{@endpoint}>"
end

def local_address_endpoint(**options)

@returns [AddressEndpoint] A endpoint for the local end of the connected socket.
A endpoint for the local end of the bound socket.
def local_address_endpoint(**options)
	AddressEndpoint.new(socket.to_io.local_address, **options)
end

def remote_address_endpoint(**options)

@returns [AddressEndpoint] A endpoint for the remote end of the connected socket.
A endpoint for the remote end of the bound socket.
def remote_address_endpoint(**options)
	AddressEndpoint.new(socket.to_io.remote_address, **options)
end

def to_s

def to_s
	"connected:#{@endpoint}"
end