/** * Connect to SOCKS Server and server will proxy remote server. * * @param host Remote server's host. * @param port Remote server's port. * @throws SocksException If any error about SOCKS protocol occurs. * @throws IOException If I/O error occurs. */ public void connect(String host, int port) throws SocksException, IOException { this.remoteServerHost = checkNotNull(host, "Argument [host] may not be null"); this.remoteServerPort = checkNotNull(port, "Argument [port] may not be null"); proxy.buildConnection(); initProxyChain(); proxy.requestConnect(remoteServerHost, remoteServerPort); }
@Override public void connect(SocketAddress endpoint, int timeout) throws SocksException, IOException { if (!(endpoint instanceof InetSocketAddress)) { throw new IllegalArgumentException("Unsupported address type"); } remoteServerHost = ((InetSocketAddress) endpoint).getHostName(); remoteServerPort = ((InetSocketAddress) endpoint).getPort(); proxy.getProxySocket().setSoTimeout(timeout); proxy.buildConnection(); initProxyChain(); proxy.requestConnect(endpoint); }