public class SocksServerSocket extends ServerSocket
SocksServerSocket
is server socket that can bind a port at SOCKS server
and accept a connection. This server socket can only accept one connection from specified IP
address and port.You can create a TCP server in SOCKS server easily by using following codes:
SocksProxy proxy = new Socks5(new InetSocketAddress("foo.com", 1080)); //Create SOCKS5 proxy. ServerSocket serverSocket = new SocksServerSocket(proxy, inetAddress, 8080); // Get bind address in SOCKS server. InetAddress bindAddress = ((SocksServerSocket) serverSocket).getBindAddress(); // Get bind port in SOKCS server. int bindPort = ((SocksServerSocket) serverSocket).getBindPort(); Socket socket = serverSocket.accept();
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
logger
Logger.
|
Constructor and Description |
---|
SocksServerSocket(SocksProxy proxy,
InetAddress inetAddress,
int port)
Constructs a server socket.
|
Modifier and Type | Method and Description |
---|---|
Socket |
accept()
Accepts a connection.
Notice: This method can be called only once. |
InetAddress |
getBindAddress() |
int |
getBindPort() |
SocketAddress |
getBindSocketAddress() |
void |
setBindAddress(InetAddress bindAddress) |
void |
setBindPort(int bindPort) |
bind, bind, close, getChannel, getInetAddress, getLocalPort, getLocalSocketAddress, getReceiveBufferSize, getReuseAddress, getSoTimeout, implAccept, isBound, isClosed, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSocketFactory, setSoTimeout, toString
public SocksServerSocket(SocksProxy proxy, InetAddress inetAddress, int port) throws SocksException, IOException
proxy
- SOCKS proxy.inetAddress
- The IP address that server socket will accept.port
- The port that server socket will accept.SocksException
- If any error about SOCKS protocol occurs.IOException
- If any I/O error occurs.public Socket accept() throws SocksException, IOException
accept
in class ServerSocket
SocksException
IOException
public InetAddress getBindAddress()
public void setBindAddress(InetAddress bindAddress)
public int getBindPort()
public void setBindPort(int bindPort)
public SocketAddress getBindSocketAddress()
Copyright © 2015. All rights reserved.