Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. long long ServerSocket::recvAll(const int &sock_fd, char *input_buffer,
  2. std::string &client_msg) {
  3. long long all_bytes_recv = 0;
  4. int bytes_read = 0;
  5. memset(input_buffer, 0, sizeof(input_buffer));
  6. bytes_read = recv(sock_fd, input_buffer, INPUT_BUFFER_SIZE, 0);
  7.  
  8. while (bytes_read > 0) {
  9. input_buffer[bytes_read] = '\0';
  10. all_bytes_recv += bytes_read;
  11. client_msg += input_buffer;
  12. bytes_read = recv(sock_fd, input_buffer, INPUT_BUFFER_SIZE, 0);
  13. }
  14.  
  15. return all_bytes_recv;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement