📄 recvmsg.3.man
字号:
'\" rtp.\" -*- nroff -*- vim: ft=nroff noautoindent nocindent nosmartindent.\".\" @(#) recvmsg.3.man,v 1.1.2.1 2004/05/16 02:35:35 brian Exp.\".\" =========================================================================.\".\" Copyright (C) 2001-2004 OpenSS7 Corporation <www.openss7.com>.\".\" All Rights Reserved..\".\" Permission is granted to make and distribute verbatim copies of this.\" manual provided the copyright notice and this permission notice are.\" preserved on all copies..\".\" Permission is granted to copy and distribute modified versions of this.\" manual under the conditions for verbatim copying, provided that the.\" entire resulting derived work is distributed under the terms of a.\" permission notice identical to this one.\" .\" Since the Linux kernel and libraries are constantly changing, this.\" manual page may be incorrect or out-of-date. The author(s) assume no.\" responsibility for errors or omissions, or for damages resulting from.\" the use of the information contained herein. The author(s) may not.\" have taken the same level of care in the production of this manual,.\" which is licensed free of charge, as they might when working.\" professionally..\" .\" Formatted or processed versions of this manual, if unaccompanied by.\" the source, must acknowledge the copyright and authors of this work..\".\" -------------------------------------------------------------------------.\".\" U.S. GOVERNMENT RESTRICTED RIGHTS. If you are licensing this Software.\" on behalf of the U.S. Government ("Government"), the following.\" provisions apply to you. If the Software is supplied by the Department.\" of Defense ("DoD"), it is classified as "Commercial Computer Software".\" under paragraph 252.227-7014 of the DoD Supplement to the Federal.\" Acquisition Regulations ("DFARS") (or any successor regulations) and the.\" Government is acquiring only the license rights granted herein (the.\" license rights customarily provided to non-Government users). If the.\" Software is supplied to any unit or agency of the Government other than.\" DoD, it is classified as "Restricted Computer Software" and the.\" Government's rights in the Software are defined in paragraph 52.227-19.\" of the Federal Acquisition Regulations ("FAR") (or any success.\" regulations) or, in the cases of NASA, in paragraph 18.52.227-86 of the.\" NASA Supplement to the FAR (or any successor regulations)..\".\" =========================================================================.\" .\" Commercial licensing and support of this software is available from.\" OpenSS7 Corporation at a fee. See http://www.openss7.com/.\" .\" =========================================================================.\".\" Last Modified 2004/05/16 02:35:35 by brian.\".\" =========================================================================.so strxnet.macros.R1bracket-label "\fR[\fB" "\fR]" "\fR, \fB"no-default-databasedatabase strxnet.refsaccumulatemove-punctuationabbreviate Ajoin-authors ", " ", " " and "et-al " et al" 2 3abbreviate-label-ranges ".."sort-adjacent-labels.R2.\".\".\".\".TH RECVMSG 3 "2004/05/16 02:35:35" "strxnet-0_9_2-4" "Linux Fast-STREAMS Sockets Library".SH NAME.B recvmsg\- receive a message from a socket.SH SYNOPSIS.PP.B #include <sys/socket.h>.HP.BI "ssize_t recvmsg(int " socket ", struct msghdr *" message ", int " flags );.SH DESCRIPTION.PPThe.BR recvmsg ()function receives a message from a connection-mode orconnectionless-mode socket. It is normally used with connectionless-modesockets because it permits the application to retrieve the source address ofreceived data..PPThe function takes the following arguments:.TP.I socketSpecifies the socket file descriptor..TP.I messagePoints to a.B msghdrstructure, containing both the buffer to store the sourceaddress and the buffers for the incoming message. The length and format of theaddress depend on the address family of the socket. The.I msg_flagsmember isignored on input, but may contain meaningful values on output..TP.I flagsSpecifies the type of message reception. Values of this argument are formed bylogically OR'ing zero or more of the following values:.RS.TP.B MSG_OOBRequests out-of-band data. The significance and semantics of out-of-band dataare protocol-specific..TP.B MSG_PEEKPeeks at the incoming message..TP.B MSG_WAITALLRequests that the function block until the full amount of data requested canbe returned. The function may return a smaller amount of data if a signal iscaught, if the connection is terminated, if.B MSG_PEEKwas specified, or if anerror is pending for the socket..RE.PPThe.BR recvmsg ()function receives messages from unconnected or connected socketsand returns the length of the message..PPThe.BR recvmsg ()function returns the total length of the message. Formessage-based sockets such as.B SOCK_DGRAMand.BR SOCK_SEQPACKET ,the entiremessage must be read in a single operation. If a message is too long to fit inthe supplied buffers, and.B MSG_PEEKis not set in the.I flagsargument, theexcess bytes are discarded, and.B MSG_TRUNCis set in the.I msg_flagsmember ofthe.B msghdrstructure. For stream-based sockets such as.BR SOCK_STREAM ,messageboundaries are ignored. In this case, data is returned to the user as soon asit becomes available, and no data is discarded..PPIf the.B MSG_WAITALLflag is not set, data will be returned only up to the endof the first message..PPIf no messages are available at the socket and.B O_NONBLOCKis not set on thesocket's file descriptor,.BR recvfrom (3)blocks until a message arrives. If nomessages are available at the socket and.B O_NONBLOCKis set on the socket'sfile descriptor,.BR recvfrom (3)function fails and sets errno to.RB [ EAGAIN ]or.RB [ EWOULDBLOCK ]..PPIn the.B msghdrstructure, the.I msg_nameand.I msg_namelenmembers specify thesource address if the socket is unconnected. If the socket is connected, the.I msg_nameand.I msg_namelenmembers are ignored. The.I msg_namemember may be anull pointer if no names are desired or required. The.I msg_iovand.I msg_iovlenfields are used to specify where the received data will be stored..I msg_iovpoints to an array of.B iovecstructures;.I msg_iovlenmust be set to thedimension of this array. In each.B iovecstructure, the iov_base field specifiesa storage area and the iov_len field gives its size in bytes. Each storagearea indicated by.I msg_iovis filled with received data in turn until all ofthe received data is stored or all of the areas have been filled..PPOn successful completion, the.I msg_flagsmember of the message header is thebitwise-inclusive OR of all of the following flags that indicate conditionsdetected for the received message:..TP.B MSG_EOREnd of record was received (if supported by the protocol)..TP.B MSG_OOBOut-of-band data was received..TP.B MSG_TRUNCNormal data was truncated..TP.B MSG_CTRUNCControl data was truncated..SH NOTES.PPThe.BR select (2)and.BR poll (2)functions can be used to determine when data isavailable to be received..SH CAVEATS.PPThis system call is implemented as a.B SIOCSOCKSYSIOCTL. See.BR socksys (4)for more information..SH CAVEATS.PPThis system call is implemented as a.B SIOCSOCKSYSIOCTL. See.BR socksys (4)for more information..SH "RETURN VALUE".PPUpon successful completion,.BR recvmsg ()returns the length of the message inbytes. If no messages are available to be received and the peer has performedan orderly shutdown,.BR recvmsg ()returns 0. Otherwise, -1 is returned and errnois set to indicate the error..SH ERRORS.PPThe.BR recvmsg ()function will fail if:.TP.RB [ EAGAIN "] or [" EWOULDBLOCK ]The socket's file descriptor is marked.B O_NONBLOCKand no data is waiting to bereceived; or.B MSG_OOBis set and no out-of-band data is available and eitherthe socket's file descriptor is marked.B O_NONBLOCKor the socket does notsupport blocking to await out-of-band data..TP.RB [ EBADF ]The.I socketargument is not a valid open file descriptor..TP.RB [ ECONNRESET ]A connection was forcibly closed by a peer..TP.RB [ EFAULT ]The.I messageparameter, or storage pointed to by the.IR msg_name ,.I msg_controlor.I msg_iovfields of the.I messageparameter, or storage pointed to by the.B iovecstructures pointed to by the.I msg_iovfield can not be accessed or written..TP.RB [ EINTR ]This function was interrupted by a signal before any data was available..TP.RB [ EINVAL ]The sum of the iov_len values overflows an.BR ssize_t .or the.B MSG_OOBflag is setand no out-of-band data is available..TP.RB [ EMSGSIZE ]The.I msg_iovlenmember of the.B msghdrstructure pointed to by.I messageis lessthan or equal to 0, or is greater than.RB { IOV_MAX }..TP.RB [ ENOTCONN ]A receive is attempted on a connection-mode socket that is not connected..TP.RB [ ENOTSOCK ]The.I socketargument does not refer to a socket..TP.RB [ EOPNOTSUPP ]The specified.I flagsare not supported for this socket type..TP.RB [ ETIMEDOUT ]The connection timed out during connection establishment, or due to atransmission timeout on active connection..PPThe.BR recvmsg ()function may fail if:.TP.RB [ EIO ]An I/O error occurred while reading from or writing to the file system..TP.RB [ ENOBUFS ]Insufficient resources were available in the system to perform the operation..TP.RB [ ENOMEM ]Insufficient memory was available to fulfill the request..TP.RB [ ENOSR ]There were insufficient.IR STREAMS (4)resources available for the operation tocomplete..SH "SEE ALSO".PP.BR poll (2),.BR recv (3),.BR recvfrom (3),.BR select (2),.BR send (3),.BR sendmsg (3),.BR sendto (3),.BR shutdown (3),.BR socket (3),.BR <sys/socket.h> (5)..SH "CONFORMING TO".PPThe Open Group XNS Issue 5.2..[xns.].\".\".[$LIST$.].TI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -