title: Using recv() to receive chunks of a message
body: <p>I am working with WebSockets. I created a small test client which splits the message and then sends it chunk by chunk. For example a message like:</p>
  
  <pre><code>PROTOCOL HTTP ACTION UPDATE
  </code></pre>
  
  <p>could be sent as </p>
  
  <pre><code>PROTOC
  </code></pre>
  
  <p>as one chunk then</p>
  
  <pre><code>OL HTT
  </code></pre>
  
  <p>as another as opposed to send the complete message in one chunk as <code>PROTOCOL HTTP ACTION UPDATE</code> which is also a possibility.</p>
  
  <p>So the way I receive the message must reflect that. Currently, I am not sure how to use <code>recv</code> when one message will be broken into multiple parts and sent across.</p>
  
  <p>This is what I am trying but I am not sure if this is the correct way. Should I always keep the size of buffer as 200 while receiving? When should I exit the loop?</p>
  
  <pre><code>void recv_all(){
              char rec_buffer[200]
              while(1) {
                ssize_t bytes_rec = recv(socket_fd, rec_buffer, sizeof(rec_buffer),0);
  
              }
  }
  </code></pre>