mirror of https://github.com/mkerrisk/man-pages
recv.2: Rework discussion of 'src_addr' and 'addrlen' for recvfrom()
The existing text was a bit opaque. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
a08d6a0720
commit
0ec495cbfb
32
man2/recv.2
32
man2/recv.2
|
@ -242,16 +242,12 @@ However, the call may still return less data than requested if
|
|||
a signal is caught, an error or disconnect occurs, or the next data to be
|
||||
received is of a different type than that returned.
|
||||
.SS recvfrom()
|
||||
.PP
|
||||
If
|
||||
.I src_addr
|
||||
is not NULL, and the underlying protocol provides the source address,
|
||||
this source address is filled in.
|
||||
When
|
||||
.I src_addr
|
||||
is NULL, nothing is filled in; in this case,
|
||||
.I addrlen
|
||||
is not used, and should also be 0.
|
||||
is not NULL,
|
||||
and the underlying protocol provides the source address of the message,
|
||||
that source address is placed in the buffer pointed to by
|
||||
.IR src_addr .
|
||||
.\" (Note: for datagram sockets in both the UNIX and Internet domains,
|
||||
.\" .I src_addr
|
||||
.\" is filled in.
|
||||
|
@ -260,17 +256,25 @@ is not used, and should also be 0.
|
|||
.\" filled in for stream sockets in the Internet domain.)
|
||||
.\" [The above notes on AF_UNIX and AF_INET sockets apply as at
|
||||
.\" Kernel 2.4.18. (MTK, 22 Jul 02)]
|
||||
The argument
|
||||
In this case,
|
||||
.I addrlen
|
||||
is a value-result argument,
|
||||
which the caller should initialize before the call to
|
||||
the size of the buffer associated with
|
||||
.IR src_addr ,
|
||||
and modified on return to indicate the actual size of the source address.
|
||||
is a value-result argument.
|
||||
Before the call,
|
||||
it should be initialized to the size of the buffer associated with
|
||||
.IR src_addr .
|
||||
Upon return,
|
||||
.I addrlen
|
||||
is updated to contain the actual size of the source address.
|
||||
The returned address is truncated if the buffer provided is too small;
|
||||
in this case,
|
||||
.I addrlen
|
||||
will return a value greater than was supplied to the call.
|
||||
|
||||
If the caller is not interested in the source address,
|
||||
.I src_addr
|
||||
should be specified as NULL and
|
||||
.I addrlen
|
||||
should be specified as 0.
|
||||
.SS recv()
|
||||
The
|
||||
.BR recv ()
|
||||
|
|
Loading…
Reference in New Issue