Module: Async::IO::Wrap::TCPSocket

Defined in:
lib/async/io/wrap/tcp.rb

Class Method Summary collapse

Class Method Details

.new(remote_host, remote_port, local_host = nil, local_port = nil) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/async/io/wrap/tcp.rb', line 44

def self.new(remote_host, remote_port, local_host=nil, local_port=nil)
	return ::TCPSocket.new(remote_host, remote_port, local_host, local_port) unless Task.current?
	
	remote_address = Async::IO::Address.tcp(remote_host, remote_port)
	
	if local_host && local_port
		local_address = Async::IO::Address.tcp(local_host, local_port)
	end
	
	return Async::IO::Socket.connect(remote_address, local_address)
end

.open(*args) ⇒ Object



56
57
58
# File 'lib/async/io/wrap/tcp.rb', line 56

def self.open(*args)
	self.new(*args)
end