title: Android socket exception (Connection reset by peer)
body: <p>I am trying to use Android's <code>VpnService</code> 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:</p>
  
  <pre><code>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());
  </code></pre>
  
  <p>However the line <code>int responseLength = socketInputStream.read(serverResponse.array());</code> is causing the following issue:</p>
  
  <blockquote>
    <p>java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)</p>
  </blockquote>
  
  <p>How can i fix this?</p>