Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

TCPSocket.new

TCPSocket.new(remote_host, remote_port, local_host=nil, local_port=nil, connect_timeout: nil)

Opens a TCP connection to remote_host on remote_port. If local_host and local_port are specified, then those parameters are used on the local end to establish the connection.

:connect_timeout

specify the timeout in seconds.

See also .gethostbyname also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0