Class: Green::TCPSocket

Inherits:
Socket
  • Object
show all
Defined in:
lib/green/socket.rb

Constant Summary

Constants inherited from Socket

Socket::READ_BUFFER_SIZE

Instance Method Summary collapse

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