Receives a message from any socket.
#include <sys/types.h> #include <sys/socket.h> #include <sys/socketvar.h>
int recvmsg (Socket, Message, Flags) int Socket; struct msghdr Message [ ]; int Flags;
The recvmsg subroutine receives messages from unconnected or connected sockets. The recvmsg 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 recvmsg subroutine waits for a message to arrive. If the socket is nonblocking and no messages are available, the recvmsg subroutine is unsuccessful.
Use the select subroutine to determine when more data arrives.
The recvmsg subroutine uses a msghdr structure to decrease the number of directly supplied parameters. The msghdr structure is defined in the sys/socket.h file. In BSD 4.3 Reno, the size and members of the msghdr structure have been modified. Applications wanting to start the old structure need to compile with COMPAT_43 defined. The default behaviour is that of BSD 4.4.
Upon successful completion, the length of the message in bytes is returned.
If the recvmsg subroutine is unsuccessful, the subroutine handler performs the following functions:
The recvmsg subroutine is unsuccessful if any of the following error codes 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. |
EINTR | The recvmsg subroutine was interrupted by delivery of a signal before any data was available for the receive. |
EFAULT | The Address parameter is not in a writable part of the user address space. |
The recvmsg subroutine is part of Base Operating System (BOS) Runtime.
All applications containing the recvmsg subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.
The no command.
The recv subroutine, recvfrom subroutine, select subroutine, send subroutine, sendmsg subroutine, sendto subroutine, shutdown subroutine, socket subroutine.
Sockets Overview and Understanding Socket Data Transfer in AIX Version 4.3 Communications Programming Concepts.