regarding recv function

hi,

the syntax of recv function is:

int recv( int sockfd, void *buffer, int length, unsigned int flags);

Suppose i declared a buffer of size 100 ,then length to be specified in recv function is sizeof(buffer) or sizeof(buffer)-1 ( i.e 100 or 99)

thanks in advance

send() and recv() send raw bytes without any consideration for their content whatsoever. If you give it a length of 100, it will use precisely 100 bytes of that buffer given sufficient data.

Remember though: A raw byte stream might not stop at a polite boundary, isn't guaranteed to give you an entire message, and won't politely null-terminate everything for you the way things like fgets() and sprintf() do. send() and recv() are raw system calls without the niceties. You get exactly what was sent, no more, no less.

1 Like

Thank you for the info.