diff options
Diffstat (limited to 'vendor/rustix/src/net/sockopt.rs')
-rw-r--r-- | vendor/rustix/src/net/sockopt.rs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/vendor/rustix/src/net/sockopt.rs b/vendor/rustix/src/net/sockopt.rs index 436d5bf86..ffdc67942 100644 --- a/vendor/rustix/src/net/sockopt.rs +++ b/vendor/rustix/src/net/sockopt.rs @@ -226,6 +226,28 @@ pub fn get_socket_timeout<Fd: AsFd>(fd: Fd, id: Timeout) -> io::Result<Option<Du backend::net::syscalls::sockopt::get_socket_timeout(fd.as_fd(), id) } +/// `getsockopt(fd, SOL_SOCKET, SO_ERROR)` +/// +/// # References +/// - [POSIX `getsockopt`] +/// - [POSIX `sys/socket.h`] +/// - [Linux `getsockopt`] +/// - [Linux `socket`] +/// - [Winsock2 `getsockopt`] +/// - [Winsock2 `SOL_SOCKET` options] +/// +/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html +/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html +/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html +/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html +/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt +/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options +#[inline] +#[doc(alias = "SO_ERROR")] +pub fn get_socket_error<Fd: AsFd>(fd: Fd) -> io::Result<Result<(), crate::io::Errno>> { + backend::net::syscalls::sockopt::get_socket_error(fd.as_fd()) +} + /// `setsockopt(fd, IPPROTO_IP, IP_TTL, ttl)` /// /// # References @@ -642,3 +664,49 @@ pub fn set_tcp_nodelay<Fd: AsFd>(fd: Fd, nodelay: bool) -> io::Result<()> { pub fn get_tcp_nodelay<Fd: AsFd>(fd: Fd) -> io::Result<bool> { backend::net::syscalls::sockopt::get_tcp_nodelay(fd.as_fd()) } + +/// `getsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE)` +/// +/// # References +/// - [POSIX `getsockopt`] +/// - [POSIX `netinet/tcp.h`] +/// - [Linux `getsockopt`] +/// - [Linux `tcp`] +/// - [Winsock2 `getsockopt`] +/// - [Winsock2 `IPPROTO_TCP` options] +/// +/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html +/// [POSIX `netinet/tcp.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_tcp.h.html +/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html +/// [Linux `tcp`]: https://man7.org/linux/man-pages/man7/tcp.7.html +/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt +/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options +#[cfg(any(apple, target_os = "freebsd"))] +#[doc(alias = "SO_NOSIGPIPE")] +#[inline] +pub fn getsockopt_nosigpipe<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::syscalls::sockopt::getsockopt_nosigpipe(fd.as_fd()) +} + +/// `setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, val)` +/// +/// # References +/// - [POSIX `getsockopt`] +/// - [POSIX `netinet/tcp.h`] +/// - [Linux `getsockopt`] +/// - [Linux `tcp`] +/// - [Winsock2 `getsockopt`] +/// - [Winsock2 `IPPROTO_TCP` options] +/// +/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html +/// [POSIX `netinet/tcp.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_tcp.h.html +/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html +/// [Linux `tcp`]: https://man7.org/linux/man-pages/man7/tcp.7.html +/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt +/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options +#[cfg(any(apple, target_os = "freebsd"))] +#[doc(alias = "SO_NOSIGPIPE")] +#[inline] +pub fn setsockopt_nosigpipe<Fd: AsFd>(fd: Fd, val: bool) -> io::Result<()> { + backend::net::syscalls::sockopt::setsockopt_nosigpipe(fd.as_fd(), val) +} |