/** * Constructs a server socket. This server socket will established in SOCKS server. * * @param proxy SOCKS proxy. * @param inetAddress The IP address that server socket will accept. * @param port The port that server socket will accept. * @throws SocksException If any error about SOCKS protocol occurs. * @throws IOException If any I/O error occurs. */ public SocksServerSocket(SocksProxy proxy, InetAddress inetAddress, int port) throws SocksException, IOException { this.proxy = proxy.copy(); this.incomePort = port; this.incomeAddress = inetAddress; this.proxy.buildConnection(); // Send BIND command to SOCKS server. CommandReplyMessage replyMesasge = this.proxy.requestBind(incomeAddress, incomePort); // Get a bind IP and port in proxy server. bindAddress = replyMesasge.getIp(); bindPort = replyMesasge.getPort(); logger.debug("Bind at {}:{}", bindAddress, bindPort); }
/** * Constructs a server socket. This server socket will established in SOCKS server. * * @param proxy SOCKS proxy. * @param inetAddress The IP address that server socket will accept. * @param port The port that server socket will accept. * @throws SocksException If any error about SOCKS protocol occurs. * @throws IOException If any I/O error occurs. */ public SocksServerSocket(SocksProxy proxy, InetAddress inetAddress, int port) throws SocksException, IOException { this.proxy = proxy.copy(); this.incomePort = port; this.incomeAddress = inetAddress; this.proxy.buildConnection(); // Send BIND command to SOCKS server. CommandReplyMessage replyMesasge = this.proxy.requestBind(incomeAddress, incomePort); // Get a bind IP and port in proxy server. bindAddress = replyMesasge.getIp(); bindPort = replyMesasge.getPort(); logger.debug("Bind at {}:{}", bindAddress, bindPort); }