title: Java TCP server - android client packet loss
body: <p>I'm trying to create a basic multiplayer game for android, using a Java TCP server and Android client. The problem is slow speed when sending TCP packets. When I put Thread.sleep(100) then it works.</p>
  
  <p>server side:</p>
  
  <pre><code>for(int i = 0; i&lt;50; i++) {
      client.send("test_" + i);
  }
  </code></pre>
  
  <p>client just received (~3 packet)<br>
  test_0<br>
  test_1</p>
  
  <p>server with sleep:</p>
  
  <pre><code>for(int i = 0; i&lt;50; i++) {
          client.send("test_" + i);
          Thread.sleep(100);
  }
  </code></pre>
  
  <p>client received ~45</p>
  
  <p>EDIT: client side:</p>
  
  <pre><code>while (true) {
  if (!running)
      break;
  inFromServer = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"), 2 * 1024);
  String rawRecervied = inFromServer.readLine();
  if (rawRecervied == null) {
      close();
      break;
  }
  final String recervied = rawRecervied.substring(2); // for skip utf bom chars
  new Thread() {
      public void run() {
          listener.dataRecervied(recervied);
          Log.e("TCP recervied", recervied); // debug
      }
  }.start();
  }
  </code></pre>