title: TCP packet comes in to the server, but not to the listening program
body: <p>So I have an Android app and a socket server. The communication seems fine when sending the first packet from the client. I get the response fine.</p>
  
  <p>However, from the second time on, when I send a packet, nothing happens. No <code>Logcat</code> nor anything in the server. I tried printing everything that comes into the server.</p>
  
  <p>So I tried to catch the packets with <code>Wireshark</code>. I saw that on the second packet, this happens.</p>
  
  <p><img src="https://i.stack.imgur.com/ll9Qo.png" alt="wireshark image"></p>
  
  <p>The packet seems to be coming in, but I don't get anything in the server program running.</p>
  
  <p>I tried running another app after one gets stuck like above, and the second app gets the response fine the first time, then the same thing.</p>
  
  <p>So I guess the server program isn't stuck anywhere or something.</p>
  
  <p>Here's the listening part of my code.</p>
  
  <pre><code>serverSocket = new ServerSocket(port);
  while (true) { // socket
      Socket clientSocket = serverSocket.accept();
  
      out = new DataOutputStream(clientSocket.getOutputStream());
      in = new DataInputStream(clientSocket.getInputStream());
  
      byte[] read = new byte[512];
      int readcount = in.read(read);
      System.out.println(bytesToHex(read)); // doesn't print from the second one
  
      if (readcount != -1) {
          if (read[0] == something) {
              HandleMsg doIt = new HandleMsg(connection, out, Arrays.copyOfRange(read, 1, readcount));
              doIt.start();
          }
          else {
              System.out.println("Got Something Unknown!");
              System.out.println(bytesToHex(Arrays.copyOfRange(read, 0, readcount)));
          }
      }
  }
  </code></pre>
  
  <p><code>connection</code> is a DB connection.</p>
  
  <p>Also, when I restart the app or the connection, it works fine the first time, and get stuck again. </p>
  
  <p>Thank you for your help.</p>