lib/net/tcp_client/tcp_client.rb
def connect_to_address(address)
      socket =
        if proxy_server
          ::SOCKSSocket.new("#{address.ip_address}:#{address.port}", proxy_server)
        else
          ::Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
        end
      unless buffered
        socket.sync = true
        socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
      end
      socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true) if keepalive

      socket_connect(socket, address, connect_timeout)

      @socket  = ssl ? ssl_connect(socket, address, ssl_handshake_timeout) : socket
      @address = address

      # Invoke user supplied Block every time a new connection has been established
      @on_connect.call(self) if @on_connect
    end
def connect_to_address(address)
      socket =
        if proxy_server
          ::SOCKSSocket.new("#{address.ip_address}:#{address.port}", proxy_server)
        else
          ::Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
        end
      unless buffered
        socket.sync = true
        socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
      end
      socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true) if keepalive

      socket_connect(socket, address, connect_timeout)

      @socket  = ssl ? ssl_connect(socket, address, ssl_handshake_timeout) : socket
      @address = address

      # Invoke user supplied Block every time a new connection has been established
      @on_connect.call(self) if @on_connect
    end
Returns [Socket] connected to supplied address
   address [Net::TCPClient::Address]
     Host name, ip address and port of server to connect to
 Connect to the server at the supplied address
 Returns the socket connection