Skip to content

Commit 64a5c6f

Browse files
committed
Document MsgFlags constants
1 parent 3e9a4fc commit 64a5c6f

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

src/sys/socket/mod.rs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,62 @@ pub enum SockType {
6060
Rdm = libc::SOCK_RDM,
6161
}
6262

63-
// Extra flags - Supported by Linux 2.6.27, normalized on other platforms
6463
bitflags!(
64+
/// Extra flags - Supported by Linux 2.6.27, normalized on other platforms
6565
pub struct SockFlag: c_int {
6666
const SOCK_NONBLOCK = 0o0004000;
6767
const SOCK_CLOEXEC = 0o2000000;
6868
}
6969
);
7070

71-
// Flags for send/recv and their relatives
7271
libc_bitflags!{
72+
/// Flags for send/recv and their relatives
7373
pub flags MsgFlags: libc::c_int {
74+
/// Sends or requests out-of-band data on sockets that support this notion
75+
/// (e.g., of type [`Stream`](enum.SockType.html)); the underlying protocol must also
76+
/// support out-of-band data.
7477
MSG_OOB,
78+
/// Peeks at an incoming message. The data is treated as unread and the next
79+
/// [`recv()`](fn.recv.html)
80+
/// or similar function shall still return this data.
7581
MSG_PEEK,
82+
/// Enables nonblocking operation; if the operation would block,
83+
/// `EAGAIN` or `EWOULDBLOCK` is returned. This provides similar
84+
/// behavior to setting the `O_NONBLOCK` flag
85+
/// (via the [`fcntl`](../../fcntl/fn.fcntl.html)
86+
/// `F_SETFL` operation), but differs in that `MSG_DONTWAIT` is a per-
87+
/// call option, whereas `O_NONBLOCK` is a setting on the open file
88+
/// description (see [open(2)](http://man7.org/linux/man-pages/man2/open.2.html)),
89+
/// which will affect all threads in
90+
/// the calling process and as well as other processes that hold
91+
/// file descriptors referring to the same open file description.
7692
MSG_DONTWAIT,
93+
/// Receive flags: Control Data was discarded (buffer too small)
7794
MSG_CTRUNC,
95+
/// For raw ([`Packet`](addr/enum.AddressFamily.html)), Internet datagram
96+
/// (since Linux 2.4.27/2.6.8),
97+
/// netlink (since Linux 2.6.22) and UNIX datagram (since Linux 3.4)
98+
/// sockets: return the real length of the packet or datagram, even
99+
/// when it was longer than the passed buffer. Not implemented for UNIX
100+
/// domain ([unix(7)](https://linux.die.net/man/7/unix)) sockets.
101+
///
102+
/// For use with Internet stream sockets, see [tcp(7)](https://linux.die.net/man/7/tcp).
78103
MSG_TRUNC,
104+
/// Terminates a record (when this notion is supported, as for
105+
/// sockets of type [`SeqPacket`](enum.SockType.html)).
79106
MSG_EOR,
107+
/// This flag specifies that queued errors should be received from
108+
/// the socket error queue. (For more details, see
109+
/// [recvfrom(2)](https://linux.die.net/man/2/recvfrom))
80110
#[cfg(any(target_os = "linux", target_os = "android"))]
81111
MSG_ERRQUEUE,
112+
/// Set the `close-on-exec` flag for the file descriptor received via a UNIX domain
113+
/// file descriptor using the `SCM_RIGHTS` operation (described in
114+
/// [unix(7)](https://linux.die.net/man/7/unix)).
115+
/// This flag is useful for the same reasons as the `O_CLOEXEC` flag of
116+
/// [open(2)](https://linux.die.net/man/2/open).
117+
///
118+
/// Only used in [`recvmsg`](fn.recvmsg.html) function.
82119
#[cfg(any(target_os = "linux", target_os = "android"))]
83120
MSG_CMSG_CLOEXEC,
84121
}

0 commit comments

Comments
 (0)