recv.2 (108028) | recv.2 (108087) |
---|---|
1.\" Copyright (c) 1983, 1990, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 16 unchanged lines hidden (view full) --- 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)recv.2 8.3 (Berkeley) 2/21/94 | 1.\" Copyright (c) 1983, 1990, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 16 unchanged lines hidden (view full) --- 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)recv.2 8.3 (Berkeley) 2/21/94 |
33.\" $FreeBSD: head/lib/libc/sys/recv.2 108028 2002-12-18 09:22:32Z ru $ | 33.\" $FreeBSD: head/lib/libc/sys/recv.2 108087 2002-12-19 09:40:28Z ru $ |
34.\" 35.Dd February 21, 1994 36.Dt RECV 2 37.Os 38.Sh NAME 39.Nm recv , 40.Nm recvfrom , 41.Nm recvmsg --- 18 unchanged lines hidden (view full) --- 60are used to receive messages from a socket, 61and may be used to receive data on a socket whether or not 62it is connection-oriented. 63.Pp 64If 65.Fa from 66is non-nil, and the socket is not connection-oriented, 67the source address of the message is filled in. | 34.\" 35.Dd February 21, 1994 36.Dt RECV 2 37.Os 38.Sh NAME 39.Nm recv , 40.Nm recvfrom , 41.Nm recvmsg --- 18 unchanged lines hidden (view full) --- 60are used to receive messages from a socket, 61and may be used to receive data on a socket whether or not 62it is connection-oriented. 63.Pp 64If 65.Fa from 66is non-nil, and the socket is not connection-oriented, 67the source address of the message is filled in. |
68.Fa Fromlen 69is a value-result parameter, initialized to the size of | 68The 69.Fa fromlen 70argument 71is a value-result argument, initialized to the size of |
70the buffer associated with 71.Fa from , 72and modified on return to indicate the actual size of the 73address stored there. 74.Pp 75The 76.Fn recv 77function is normally used only on a 78.Em connected 79socket (see 80.Xr connect 2 ) 81and is identical to 82.Fn recvfrom 83with a nil 84.Fa from | 72the buffer associated with 73.Fa from , 74and modified on return to indicate the actual size of the 75address stored there. 76.Pp 77The 78.Fn recv 79function is normally used only on a 80.Em connected 81socket (see 82.Xr connect 2 ) 83and is identical to 84.Fn recvfrom 85with a nil 86.Fa from |
85parameter. | 87argument. |
86As it is redundant, it may not be supported in future releases. 87.Pp 88All three routines return the length of the message on successful 89completion. 90If a message is too long to fit in the supplied buffer, 91excess bytes may be discarded depending on the type of socket 92the message is received from (see 93.Xr socket 2 ) . --- 49 unchanged lines hidden (view full) --- 143However, the call may still return less data than requested 144if a signal is caught, an error or disconnect occurs, 145or the next data to be received is of a different type than that returned. 146.Pp 147The 148.Fn recvmsg 149system call uses a 150.Fa msghdr | 88As it is redundant, it may not be supported in future releases. 89.Pp 90All three routines return the length of the message on successful 91completion. 92If a message is too long to fit in the supplied buffer, 93excess bytes may be discarded depending on the type of socket 94the message is received from (see 95.Xr socket 2 ) . --- 49 unchanged lines hidden (view full) --- 145However, the call may still return less data than requested 146if a signal is caught, an error or disconnect occurs, 147or the next data to be received is of a different type than that returned. 148.Pp 149The 150.Fn recvmsg 151system call uses a 152.Fa msghdr |
151structure to minimize the number of directly supplied parameters. | 153structure to minimize the number of directly supplied arguments. |
152This structure has the following form, as defined in 153.Ao Pa sys/socket.h Ac : 154.Pp 155.Bd -literal 156struct msghdr { 157 caddr_t msg_name; /* optional address */ 158 u_int msg_namelen; /* size of address */ 159 struct iovec *msg_iov; /* scatter/gather array */ --- 6 unchanged lines hidden (view full) --- 166.Pp 167Here 168.Fa msg_name 169and 170.Fa msg_namelen 171specify the destination address if the socket is unconnected; 172.Fa msg_name 173may be given as a null pointer if no names are desired or required. | 154This structure has the following form, as defined in 155.Ao Pa sys/socket.h Ac : 156.Pp 157.Bd -literal 158struct msghdr { 159 caddr_t msg_name; /* optional address */ 160 u_int msg_namelen; /* size of address */ 161 struct iovec *msg_iov; /* scatter/gather array */ --- 6 unchanged lines hidden (view full) --- 168.Pp 169Here 170.Fa msg_name 171and 172.Fa msg_namelen 173specify the destination address if the socket is unconnected; 174.Fa msg_name 175may be given as a null pointer if no names are desired or required. |
174.Fa Msg_iov | 176The 177.Fa msg_iov |
175and 176.Fa msg_iovlen | 178and 179.Fa msg_iovlen |
180arguments |
|
177describe scatter gather locations, as discussed in 178.Xr read 2 . | 181describe scatter gather locations, as discussed in 182.Xr read 2 . |
179.Fa Msg_control , | 183The 184.Fa msg_control 185argument, |
180which has length 181.Fa msg_controllen , 182points to a buffer for other protocol control related messages 183or other miscellaneous ancillary data. 184The messages are of the form: 185.Bd -literal 186struct cmsghdr { 187 u_int cmsg_len; /* data byte count, including hdr */ --- 112 unchanged lines hidden --- | 186which has length 187.Fa msg_controllen , 188points to a buffer for other protocol control related messages 189or other miscellaneous ancillary data. 190The messages are of the form: 191.Bd -literal 192struct cmsghdr { 193 u_int cmsg_len; /* data byte count, including hdr */ --- 112 unchanged lines hidden --- |