mirror of https://github.com/mkerrisk/man-pages
unix.7: Ancillary data forms a barrier when receiving on a stream socket
Thanks to a tip from Keith Packard: https://keithp.com/blogs/fd-passing/ (Also verified by experiment.) Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
5219daec26
commit
5af0f223d1
27
man7/unix.7
27
man7/unix.7
|
@ -455,6 +455,33 @@ it is not necessary on Linux to send any accompanying real data.
|
||||||
However, portable applications should also include at least one byte
|
However, portable applications should also include at least one byte
|
||||||
of real data when sending ancillary data over a datagram socket.
|
of real data when sending ancillary data over a datagram socket.
|
||||||
.PP
|
.PP
|
||||||
|
When receiving from a stream socket,
|
||||||
|
ancillary data forms a kind of barrier for the received data.
|
||||||
|
For example, suppose that the sender transmits as follows:
|
||||||
|
.PP
|
||||||
|
.RS
|
||||||
|
.PD 0
|
||||||
|
.IP 1. 3
|
||||||
|
.BR sendmsg (2)
|
||||||
|
of four bytes, with no ancillary data.
|
||||||
|
.IP 2.
|
||||||
|
.BR sendmsg (2)
|
||||||
|
of one byte, with ancillary data.
|
||||||
|
.IP 3.
|
||||||
|
.BR sendmsg (2)
|
||||||
|
of four bytes, with no ancillary data.
|
||||||
|
.PD
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
|
Suppose that the receiver now performs
|
||||||
|
.BR recvmsg (2)
|
||||||
|
calls each with a buffer size of 20 bytes.
|
||||||
|
The first call will receive five bytes of data,
|
||||||
|
along with the ancillary data sent by the second
|
||||||
|
.BR sendmsg (2)
|
||||||
|
call.
|
||||||
|
The next call will receive the remaining five bytes of data.
|
||||||
|
.PP
|
||||||
If the space allocated for receiving incoming ancillary data is too small
|
If the space allocated for receiving incoming ancillary data is too small
|
||||||
then the ancillary data is truncated to the number of headers
|
then the ancillary data is truncated to the number of headers
|
||||||
that will fit in the supplied buffer (or, in the case of an
|
that will fit in the supplied buffer (or, in the case of an
|
||||||
|
|
Loading…
Reference in New Issue