SocksLib provides several ways to use a SOCKS5 client depending on the required operation:
CONNECT
Use Socks5 to define the proxy and SocksSocket to establish a connection to a remote address.
BIND
Use SocksServerSocket to listen for incoming connections through the proxy.
UDP ASSOCIATE
Use Socks5DatagramSocket for UDP-based communication through the proxy.
// CONNECT
SocksProxy proxy = new Socks5(new InetSocketAddress("localhost", 1080));
Socket socket = new SocksSocket(proxy, new InetSocketAddress("whois.internic.net", 43));
// BIND
SocksServerSocket serverSocket = new SocksServerSocket(proxy, inetAddress, 8080);
InetAddress bindAddress = serverSocket.getBindAddress();
int bindPort = serverSocket.getBindPort();
Socket socket = serverSocket.accept();
// UDP ASSOCIATE
DatagramSocket socket = new Socks5DatagramSocket(proxy);