title: How can I send many matrices from server to client at the same time and vice versa in c++ using TCP/IP?
body: <p>I have in my code two calls on the server side for two functions <strong>sendMatrixPos</strong> and <strong>sendMatrixTrack</strong> to send two matrices sequentially. and I sent the matrices evrey fram to the client </p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>void MyTestPlugin::sendMSGP()
  {
      if(!connected)
          return;
      if ( (numbytes = send(client_skt, buf, 16*sizeof(float) ,0)) == -1){
          std::cerr&lt;&lt;"server, normal send error"&lt;&lt;std::endl;
          exit(1);
      }
  }
  
  void MyTestPlugin::sendMSGT()
  {
      if(!connected)
          return;
      if ( (numbytes = send(client_skt, trackBuf, 16*sizeof(float) ,0)) == -1){
          std::cerr&lt;&lt;"server, normal send error"&lt;&lt;std::endl;
          exit(1);
      }
  }
  
  void MyTestPlugin::sendMatrixPos()
  {
      if(!connected)
          return;
  
     Matrixd transNode = PluginHelper::getObjectMatrix();
  
     for (int i=0; i&lt;4; ++i)
       for (int j=0; j&lt;4; ++j)
          matrixP[i*4+j] = transNode(i,j);
  
     for(int i=0; i&lt;16; i++)
     {
       cerr &lt;&lt;"matrixP:" &lt;&lt; i &lt;&lt; "   " &lt;&lt; matrixP[i] &lt;&lt; endl;
     }
  
      memcpy(buf,matrixP,sizeof(float)*16);
      sendMSGP();
  }
  
  void MyTestPlugin::sendMatrixTrack()
  {
  
      if(!connected)
          return;
     Matrixd trackNode = PluginHelper::getHeadMat(1);
  
     for (int i=0; i&lt;4; ++i)
       for (int j=0; j&lt;4; ++j)
          matrixT[i*4+j] = trackNode(i,j);
  
     for(int i=0; i&lt;16; i++)
     {
       cerr &lt;&lt;"matrixT:" &lt;&lt; i &lt;&lt; "   " &lt;&lt; matrixT[i] &lt;&lt; endl;
     }
  
      memcpy(trackBuf,matrixT,sizeof(float)*16);
      sendMSGT();
  }
  
  void MyTestPlugin::preFrame()
  { 
    sendMatrixPos();   
    sendMatrixTrack();
  }
  </code></pre>
  
  <p>On the otherside, I have two calls on the client for a function to receive two matrices sequentially from the server every frame..</p>
  
  <p><strong>client</strong></p>
  
  <pre><code>void osgMain::draw()
  {
      recvMSG();
      ...
      recvMSG();
  }
  
  
  void osgMain::recvMSG()
  {
      numbytes = recv(client_skt, buf, bufferSize,0);
          if ( numbytes == -1 ){
              //__android_log_print(ANDROID_LOG_ERROR,"jni client","recv error");
              //exit(1);
          }
          else
          {
              memcpy (matrix, buf, numbytes);
          }
  }
  </code></pre>
  
  <p>I used TCP/IP protocol. I need to send the two matrices and receive them at the same time (not sequentially), How can I do this step? or How can I send two matrices at the same time?</p>
  
  <p>the BUFFERSIZE 1024 on the client side and also 1024 on the server side...</p>