title: Receive the multiple message socket programming C
body: <p>Hi I new to socket programming C. Now I working on chat program and I successful can sending and receiving message but the problem is when client request to send list of user that client online and once server send message back to client the message is successful print the list of current connected client but once it display it not going out of loop. below is only one section of the code.</p>
  
  <p>server side (server.c)</p>
  
  <pre><code>pthread_mutex_lock(&amp;list_mutex);
     for(i =0; i &lt; NotEndOfList; i++)
     {
  
      sprintf(message_replay, "Server: %s \n", usersList[i].name); 
      write(sock , message_replay , strlen(message_replay));  
  
    }
    pthread_mutex_unlock(&amp;list_mutex);
  </code></pre>
  
  <p>Client side (Client.c)</p>
  
  <pre><code>int i =0;
            while(i &lt; NotEndOfList)
           {
              if( recv(sock , server_reply , 2000 , 0) &lt; 0)
              {
                puts("recv failed");
                break;
              }
           i++;
  
          puts(server_reply);
        }
  </code></pre>
  
  <p>Sample Output</p>
  
  <pre><code>    User A --&gt;:
      //List 
      User A
      User B
      User C
      // Loop
  </code></pre>
  
  <p>Correct Sample Output</p>
  
  <pre><code>User A --&gt;:
  //List
  User A
  User B
  User C
  User A --&gt;:
  </code></pre>
  
  <p>Thank you very much</p>