The socket call receives data on a socket.
Syntax
#include <types.h> #include <sys\socket.h> int recvfrom(s, buf, len, flags, name, namelen) int s; char *buf; int len; int flags; struct sockaddr *name; int *namelen;
Parameters
s
MSG_DONTWAIT
Description
The recvfrom() call receives data on a socket with descriptor s and stores it in a buffer. The recvfrom() call applies to any socket type, whether connected or not.
If name is nonzero, the address of the data sender is returned. The namelen parameter is first initialized to the size of the buffer associated with name; on return, it is modified to indicate the actual number of bytes stored there.
The recvfrom() call returns the length of the incoming message or data. If a datagram or sequenced packet is too long to fit in the supplied buffer, the excess is discarded. No data is discarded for stream or sequenced packet sockets. If data is not available at the socket with descriptor s, the recvfrom() call waits for data to arrive and blocks the caller, unless the socket is in nonblocking mode. See ioctl() for a description of how to set nonblocking mode.
Return Values
When successful, the number of bytes of data received into the buffer is returned. The value -1 indicates an error. You can get the specific error code by calling sock_errno() or psock_errno().
Error Code
Related Calls
ioctl() readv()
recv()
recvmsg()
select()
send()
sendmsg()
sendto()
setsockopt()
shutdown()
sock_errno()
socket()
writev()