title: How to continuously send and receive packets?
body: <p>I am programming a server / client communication system where a client requests to log in to the server and can request to view other client's online status. I can make the client log in fine, but when I try to log in (successfully) and then send another packet requesting another client's information, the server does not receive that packet. </p>
  
  <p>the main part of the server, not the technical connection stuff starting from bind Server:</p>
  
  <pre><code>Users client[2]; //I intialized them already
  
  //Bind
  bind(WelcomeSocket, (sockaddr*)&amp;SvrAddr, sizeof(SvrAddr));
  
  //listening
  listen(WelcomeSocket, 5);
  
  //temp users
  Users temp;
  
  //while loop for the connection 
  while (1) {
  
      ConnectionSocket = accept(WelcomeSocket, NULL, NULL);
  
  
  
      if (recv(ConnectionSocket, RxBuffer, sizeof(RxBuffer), 0))
          cout &lt;&lt; "WORKEDDDDDDDD" &lt;&lt; endl;
  
      memcpy(&amp;temp, RxBuffer, sizeof(struct Users));
  
      cout &lt;&lt; temp.message &lt;&lt; temp.userName &lt;&lt; endl &lt;&lt; endl;
  
      //check which message type is being sent
      switch(temp.message) {
  
      //if message type 1
      case 1 :
          for (int i = 0; i &lt; 2; i++) {
  
              //if receieved username matches with any username in the database
              if (strcmp(temp.userName, client[i].userName) == 0) {
  
                  //assign the recieved users information to the matched one in database
                  strcpy(client[i].userName, temp.userName);
                  client[i].online = true;
                  client[i].message = 2;
  
                  cout &lt;&lt; client[i].userName &lt;&lt; endl &lt;&lt; client[i].online &lt;&lt; endl;
  
                  //send the acknowledgement packet
                  send(ConnectionSocket, (char *)&amp;client[i], sizeof(struct Users), 0);
              }
  
          }
          closesocket(ConnectionSocket);
          break;
  
      //if message type 3
      case 3 :
          cout &lt;&lt; "3";
          break;
  
      default :
          break;
  
      }
  
  }
  
  closesocket(ConnectionSocket);
  WSACleanup();
  }
  </code></pre>
  
  <p>Client: </p>
  
  <pre><code>connect(ClientSocket, (sockaddr*)&amp;SvrAddr, sizeof(SvrAddr));
  
  
  
  //cout &lt;&lt; "Name: ";
  //cin &gt;&gt; login;
  
  //Send request to login
  int log;
  char * name = new char[128];
  char * request = new char[128];
  Users client;
  Users talkto;
  
  
  
      cout &lt;&lt; "To login press (1). ";
      cin &gt;&gt; log;
      flushall();
  
      if (log == 1) {
  
          cout &lt;&lt; "Username : ";
          cin.getline(name, 128, '\n');
          flushall();
  
          //Set client login info
          strcpy(client.userName, name);
          client.message = 1;
  
  
  
          send(ClientSocket, (char *)&amp;client, sizeof(struct Users), 0);
  
  
          //Recieve acknowledgement
          recv(ClientSocket, RxBuffer, sizeof(RxBuffer), 0);
          //create temp users
          Users temp;
  
          memcpy(&amp;temp, RxBuffer, sizeof(struct Users));
  
  
  
          if (temp.message == 2) {
  
              cout &lt;&lt; "Enter user for user information: ";
              cin.getline(talkto.userName, 128, '\n');
              flushall();
              talkto.message = 3;
  
              //send request for user information packet
              if (send(ClientSocket, (char *)&amp;talkto, sizeof(struct Users), 0))
              cout &lt;&lt; "SENDT" &lt;&lt; endl;
          }
  
          //cout &lt;&lt; temp.userName &lt;&lt; endl &lt;&lt; temp.online &lt;&lt; endl &lt;&lt; temp.message;
  
          closesocket(ClientSocket);
  
  
  WSACleanup();
  </code></pre>
  
  <p>}</p>
  
  <p>The structure for users</p>
  
  <pre><code>struct Users {
  
  int message;
  char userName[50];
  char ipAddress[50];
  int PortNumber;
  bool online;
  
  };
  </code></pre>
  
  <p>Not sure why it's not receiving information more than one time</p>