recvfrom
recvfrom is a function in the Berkeley sockets API used to receive data from a socket, with the ability to obtain the address of the sender. It is especially common for datagram sockets (UDP) where knowing the source is essential for responding or logging, but it can be used with other socket types as well. The function fills a user-provided buffer with incoming data and, if requested, stores the sender's address in a separate buffer.
In POSIX systems, the typical prototype is ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, struct
Return value is the number of bytes received, or -1 (or SOCKET_ERROR on Windows) on error. In
Compared with recv, recvfrom adds the ability to capture the sender’s address, which is particularly useful