I am trying to use Android's VpnService
to forward packets to their original destination after i receive them. After writing data to the socket with the correct destination address, I am trying to get the response like this:
Socket socket = SocketChannel.open().socket();
socket.connect(new InetSocketAddress(ipPacket.getDestinationIp(), ipPacket.getDstPort()));
ByteBuffer serverResponse = ByteBuffer.allocate(65535);
InputStream socketInputStream = socket.getInputStream();
int responseLength = socketInputStream.read(serverResponse.array());
However the line int responseLength = socketInputStream.read(serverResponse.array());
is causing the following issue:
java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
How can i fix this?