int recv(int sockfd, void *buf, int len, int flags);
Parameters
sockfd is the socket descriptor to read from
buf is the buffer to read the information into
len is the maximum length of the buffer
flags can again be set to 0
return values
recv() returns the number of bytes actually read into the buffer
-1 on error (with errno set, accordingly).
recv() can return 0. This can mean only one thing: the remote side has closed the connection on you! A return value of 0 is recv()’s way of letting you know this has occurred.