title: Android TCP multicast missing message
body: <p>I build a TCP multicast chat application using asynctask.
  I am also trying to order the message in FIFO and causal order.</p>
  
  <p>However, when I try to send a lot of messages simultaneously for testing, it misses some messages but I can't find the reason.
  I have tried as hard as I can to improve the performance of the program because I thought the performance could be the reason. but still having the same issue. 
  I attached some important part of my code.
  Most of all,</p>
  
  <pre><code>    private class ServerTask extends AsyncTask&lt;ServerSocket, String, Void&gt; {
  
      @Override
      protected Void doInBackground(ServerSocket... sockets){
          ServerSocket serverSocket = sockets[0];
          Socket socket = new Socket();
          try {
              while(true) {
                  socket = serverSocket.accept();
                  InputStream inputstream = socket.getInputStream();
                  DataInputStream in = new DataInputStream(new BufferedInputStream(inputstream));
  
                  String msg = ""+in.readUTF();
                  String time = ""+in.readUTF();
  
                  String temp = time+"||"+msg;
                  publishProgress(temp);
                  in.close();
  
  
              }} catch (IOException e) {
              e.printStackTrace();
          } finally{
              try {
                  socket.close();
                  serverSocket.close();////
              } catch (IOException e) {
                  e.printStackTrace();
              }
  
          }
  
          return null;
      }
  </code></pre>
  
  <p>Here is onProgressUpdate.</p>
  
  <pre><code>        protected void onProgressUpdate(String...strings) {
          /*
           * The following code displays what is received in doInBackground().
           */
          String strReceived = strings[0].trim();
          TextView remoteTextView = (TextView) findViewById(R.id.textView1);
          remoteTextView.append(strReceived + "\t\n");
          try {
              sequencer(strReceived);
          } catch (ParseException e) {
              e.printStackTrace();
          }
  
  
          return;
      }
  }
  </code></pre>
  
  <p>..</p>
  
  <pre><code>   private class ClientTask extends AsyncTask&lt;String, Void, Void&gt; {
  
      @Override
      protected Void doInBackground(String... msgs) {
  
          Date currentDate= new Date();
          Timestamp time = new Timestamp(currentDate.getTime());
          Message temp = new Message(myPort, msgs[0], time);////
          try {
  
              for(int i = 0; i &lt;= 2; i++) {
                  Socket socket = new Socket();
                  socket.connect(new InetSocketAddress(InetAddress.getByAddress(new byte[]{10, 0, 2, 2}),
                          Integer.parseInt(REMOTE_PORTS[i])), 1000);
                  socket.setTcpNoDelay(true);
                  OutputStream outputStream = socket.getOutputStream();
                  DataOutputStream o = new DataOutputStream(new BufferedOutputStream(outputStream));
  
                  o.writeUTF(msgs[0]);
                  o.writeUTF(""+time);
                  o.flush();////
                  socket.close();
              }
          }
          catch (UnknownHostException e) {
              Log.e(TAG, "ClientTask UnknownHostException");
          } catch (IOException e) {
              Log.e(TAG, "ClientTask socket IOException");
          }
  
          return null;
      }
  </code></pre>
  
  <p>Can you find the part causes the problem?</p>