Receives messages from sockets.
#include <sys/types.h> #include <sys/socket.h> #include <sys/socket.h>
int recvfrom (Socket, Buffer, Length, Flags, From, FromLength) int Socket; char *Buffer; int Length, Flags; struct sockaddr *From; int *FromLength;
The recvfrom subroutine allows an application program to receive messages from unconnected sockets. The recvfrom subroutine is normally applied to unconnected sockets as it includes parameters that allow the calling program to specify the source point of the data to be received.
To return the source address of the message, specify a nonnull value for the From parameter. The FromLength parameter is a value-result parameter, initialized to the size of the buffer associated with the From parameter. On return, the recvfrom subroutine modifies the FromLength parameter to indicate the actual size of the stored address. The recvfrom subroutine returns the length of the message. If a message is too long to fit in the supplied buffer, excess bytes may be truncated depending on the type of socket that issued the message.
If no messages are available at the socket, the recvfrom subroutine waits for a message to arrive, unless the socket is nonblocking. If the socket is nonblocking, the system returns an error.
If the recvfrom subroutine is successful, the subroutine returns the length of the message in bytes.
If the call is unsuccessful, the subroutine handler performs the following functions:
The recvfrom subroutine is unsuccessful if any of the following errors occurs:
EBADF | The Socket parameter is not valid. |
ENOTSOCK | The Socket parameter refers to a file, not a socket. |
EWOULDBLOCK | The socket is marked nonblocking, and no connections are present to be accepted. |
EFAULT | The data was directed to be received into a nonexistent or protected part of the process address space. The buffer is not valid. |
The recvfrom subroutine is part of Base Operating System (BOS) Runtime.
The socket applications can be compiled with COMPAT_43 defined. This will make the sockaddr structure BSD 4.3 compatible. For more details refer to socket.h.
The fgets subroutine, fputs subroutine, read subroutine, recv subroutine, recvmsg subroutine, select subroutine, send subroutine, sendmsg subroutine, sendto subroutine, shutdown subroutine, socket subroutine, write subroutine.
Sockets Overview and Understanding Socket Data Transfer in AIX Version 4.3 Communications Programming Concepts.