recv() will read any data that there is to be read, and set its return value to the amount of data that has been read, in bytes. There is no guarentee that all of the data will be read at once (although you can modify the behaviour by changing the socket's file-descriptor flags with select()). You can also try the MSG_WAITALL flag to recv() but that still doesn't guarentee getting all of the data at once.
If an error has occurred, read() will set errno to the value of the error. You can test for errors with: (remember to use #include<errno.h> and #include<string.h>)
Code:
errno = 0;
if (len > recv(from,buffer,len,MSG_WAITALL)) {
printf("Error: %s\n", strerror(errno);
}