What this function recvfrom() does?
Beginners Guide to Sockets
(Continued from previous question...)
What this function recvfrom() does?
Receiving on a Named Socket - recvfrom()
#include <sys/types.h>
#include <sys/socket.h>
int recvfrom(int s, char *msg, int len,
int flags,struct sockaddr *from, int *fromlen)
This function allows a message msg of maximum length len to be read
from a socket with descriptor s from the socket named by from and
fromlen, where fromlen is the actual length of from. The number of
characters actually read from the socket is the return value of the
function. On error, -1 is returned and errno describes the error. flags
may be 0, or may specify MSG_PEEK to examine a message without actually
receiving it from the queue.
If no message is available to be read, the process will suspend waiting
for one unless the socket is set to nonblocking mode (via an ioctl
call).
The system I/O call read() can also be used to read data from a socket.
(Continued on next question...)
Other Interview Questions
|