Class: Green::TCPSocket
Constant Summary
Constants inherited from Socket
Instance Method Summary collapse
-
#initialize(remote_host, remote_port, local_host = nil, local_port = nil) ⇒ TCPSocket
constructor
A new instance of TCPSocket.
Methods inherited from Socket
#accept, accept_socket_class, #connect, #kgio_wait_readable, #read, #recv, #send, #waiter, #write
Constructor Details
#initialize(remote_host, remote_port, local_host = nil, local_port = nil) ⇒ TCPSocket
Returns a new instance of TCPSocket.
96 97 98 99 100 101 102 103 |
# File 'lib/green/socket.rb', line 96 def initialize(remote_host, remote_port, local_host = nil, local_port = nil) addrinfo = Addrinfo.tcp(remote_host, remote_port) super(addrinfo.ipv4? ? :INET : :INET6, :STREAM, 0) if local_host && local_port bind(Addrinfo.tcp(local_host, local_port)) end connect addrinfo end |