The recvmsg() call uses a msghdr structure to minimize the number of directly supplied arguments. However, the call may still return less data than requested if a signal isĬaught, an error or disconnect occurs, or the next data to be received is of a different type than that returned. This flag requests that the operation block until the full request is satisfied. Not implemented for UNIX domain ( unix(7)) sockets.įor use with Internet stream sockets, see tcp(7). The real length of the packet or datagram, even when it was longer than the passed buffer. Thus, a subsequentįor raw ( AF_PACKET), Internet datagram (since Linux 2.4.27/2.6.8), netlink (since Linux 2.6.22) and UNIX datagram (since Linux 3.4) sockets: return MSG_PEEK This flag causes the receive operation to return data from the beginning of the receive queue without removing that data from the queue. Normal data queue, and thus this flag cannot be used with such protocols. Some protocols place expedited data at the head of the MSG_OOB This flag requests receipt of out-of-band data that would not be received in the normal data stream. The payload of the packet that caused the error is passed as normal data. If this address is not known, the sa_family member of the sockaddr contains AF_UNSPEC and the other fields of The macro SOCK_EE_OFFENDER returns a pointer to the address of the network object where the error originated from given a pointer ee_origin is the origin code of where the error originated. Struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err *) ee_errno contains the errno number of the queued error. Uint32_t ee_info /* additional information */ Uint8_t ee_origin /* where the error originated */ The error is supplied in a sock_extended_err structure: Will be passed on the next socket operation. After an error has been passed, the pending socket error is regenerated based on the next queued error and The original destination address of the datagram thatĬaused the error is supplied via msg_name.įor local errors, no address is passed (this can be checked with the cmsg_len member of the cmsghdr). Payload of the original packet that caused the error is passed as normal data via msg_iovec. See cmsg(3) and ip(7) for more information. The user should supply a buffer of sufficient size. The error is passed in an ancillary message with a type dependent on This flag specifies that queued errors should be received from the socket error queue. Using the O_NONBLOCK flag with the F_SETFL fcntl(2)). This flag is useful for the same reasons as the O_CLOEXEC flag of open(2).Įnables nonblocking operation if the operation would block, the call fails with the error EAGAIN or EWOULDBLOCK (this can also be enabled Set the close-on-exec flag for the file descriptor received via a UNIX domain file descriptor using the SCM_RIGHTS operation (described in MSG_CMSG_CLOEXEC ( recvmsg() only since Linux 2.6.23) The flags argument to a recv() call is formed by ORing one or more of the following values: The select(2) or poll(2) call may be used to determine when more data arrives. The receive calls normally return any dataĪvailable, up to the requested amount, rather than waiting for receipt of the full amount requested. If no messages are available at the socket, the receive calls wait for a message to arrive, unless the socket is nonblocking (see fcntl(2)), in whichĬase the value -1 is returned and the external variable errno is set to EAGAIN or EWOULDBLOCK. If a message is too long to fit in the supplied buffer, excess bytes may beĭiscarded depending on the type of socket the message is received from. The recv() call is normally used only on a connected socket (see connect(2)) and is identical to recvfrom() with a NULLĪll three routines return the length of the message on successful completion. The returned address is truncated if the buffer provided is too small in this case, addrlen will return a value greater than was The argument addrlen is a value-result argument, which theĬaller should initialize before the call to the size of the buffer associated with src_addr, and modified on return to indicate the actual size of the Nothing is filled in in this case, addrlen is not used, and should also be NULL. If src_addr is not NULL, and the underlying protocol provides the source address, this source address is filled in. The recvfrom() and recvmsg() calls are used to receive messages from a socket, and may be used to receive data on a socket whether or not it
0 Comments
Leave a Reply. |