Receives a message from any socket.
Standard C Library (libc.a)
int recvmsg ( Socket, Message, Flags)
struct msghdr Message [ ];
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 thesys/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 behavior is that of BSD 4.4.
|Socket||Specifies the unique name of the socket.|
|Message||Points to the address of the msghdr structure, which contains both the address for the incoming message and the space for the sender address.|
|Flags||Permits the subroutine to exercise control over the reception of
messages. The Flags parameter used to receive a call is
formed by logically ORing one or more of the values shown in the following
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 5L Version 5.1 Communications Programming Concepts.