When trying to use DatagramSocket.connect on a derived Socks5DatagramSocket, you will run into IllegalArgumentException "connected address and packet address differ". This is because the connect method is not overloaded to connect to the relayInetSocketAddress. This way, the socket is actually connected to the final destination address, leading to an address conflict with the encapsulated DatagramPacket.
To fix, overload connect() to transparently connect to relayInetSocketAddress instead. Additionally, you should store the InetSocketAddress given to connect by the caller and check equals in the overloaded send methods.
When trying to use DatagramSocket.connect on a derived Socks5DatagramSocket, you will run into IllegalArgumentException "connected address and packet address differ". This is because the connect method is not overloaded to connect to the relayInetSocketAddress. This way, the socket is actually connected to the final destination address, leading to an address conflict with the encapsulated DatagramPacket. To fix, overload connect() to transparently connect to relayInetSocketAddress instead. Additionally, you should store the InetSocketAddress given to connect by the caller and check equals in the overloaded send methods.