I've been reading through beejs guide to networking to get a handle on TCP connections. In one of the samples the Client code for a simple TCP stream client looks like:
if ((numbytes = recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) {
perror("recv");
exit(1);
}
buf[numbytes] = '\0';
printf("client: received '%s'\n",buf);
close(sockfd);
I've set the buffer to be smaller then the total number of bytes that I'm sending. I'm not quite sure how I can get the other bytes, Do I have to loop over recv() until I receive '\0'?
*Note on the serverside I'm also implementing his sendall() function so it should actually be sending everything to the client.