java.lang.Object
net.i2p.socks.SOCKS5Client

public class SOCKS5Clientextends Object
A simple SOCKS 5 client. Note: Caller is advised to setSoTimeout on the socket. Not done here.
  • Constructor Details

    • SOCKS5Client

      private SOCKS5Client()
      Utility class, not intended for instantiation.
  • Method Details

    • connect

      public static void connect(Socket sock, String connHostName, int connPort) throws IOException
      Act as a SOCKS 5 client to connect to a proxy

      Will throw and close sock on all errors. Caller must close sock on success.

      Parameters:
      sock - socket to the proxy
      connHostName - hostname for the proxy to connect to
      connPort - port for the proxy to connect to
      Throws:
      IOException - if the connection fails or the proxy rejects the request
    • connect

      public static void connect(Socket sock, String connHostName, int connPort, String configUser, String configPW) throws IOException
      Act as a SOCKS 5 client to connect to a proxy

      Will throw and close sock on all errors. Caller must close sock on success.

      Parameters:
      sock - socket to the proxy
      connHostName - hostname for the proxy to connect to
      connPort - port for the proxy to connect to
      configUser - username for proxy authentication or null
      configPW - password for proxy authentication or null
      Throws:
      IOException - if the connection fails or the proxy rejects the request
    • connect

      public static void connect(InputStream pin, OutputStream pout, String connHostName, int connPort) throws IOException
      Act as a SOCKS 5 client to connect to a proxy

      Will throw and close pin and pout on all errors. Caller must close pin and pout on success.

      Parameters:
      pin - input stream from the proxy
      pout - output stream to the proxy
      connHostName - hostname for the proxy to connect to
      connPort - port for the proxy to connect to
      Throws:
      IOException - if the connection fails or the proxy rejects the request
    • connect

      public static void connect(InputStream pin, OutputStream pout, String connHostName, int connPort, String configUser, String configPW) throws IOException
      Act as a SOCKS 5 client to connect to a proxy

      Will throw and close pin and pout on all errors. Caller must close pin and pout on success.

      Parameters:
      pin - input stream from the proxy
      pout - output stream to the proxy
      connHostName - hostname for the proxy to connect to
      connPort - port for the proxy to connect to
      configUser - username for proxy authentication or null
      configPW - password for proxy authentication or null
      Throws:
      IOException - if the connection fails or the proxy rejects the request