| 1 | use crate::fd::OwnedFd; |
| 2 | use crate::net::{AddressFamily, Protocol, SocketFlags, SocketType}; |
| 3 | use crate::{backend, io}; |
| 4 | |
| 5 | /// `socketpair(domain, type_ | accept_flags, protocol)`—Create a pair of |
| 6 | /// sockets that are connected to each other. |
| 7 | /// |
| 8 | /// # References |
| 9 | /// - [POSIX] |
| 10 | /// - [Linux] |
| 11 | /// - [Apple] |
| 12 | /// - [FreeBSD] |
| 13 | /// - [NetBSD] |
| 14 | /// - [OpenBSD] |
| 15 | /// - [DragonFly BSD] |
| 16 | /// - [illumos] |
| 17 | /// - [glibc] |
| 18 | /// |
| 19 | /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/socketpair.html |
| 20 | /// [Linux]: https://man7.org/linux/man-pages/man2/socketpair.2.html |
| 21 | /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/socketpair.2.html |
| 22 | /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=socketpair&sektion=2 |
| 23 | /// [NetBSD]: https://man.netbsd.org/socketpair.2 |
| 24 | /// [OpenBSD]: https://man.openbsd.org/socketpair.2 |
| 25 | /// [DragonFly BSD]: https://man.dragonflybsd.org/?command=socketpair§ion=2 |
| 26 | /// [illumos]: https://illumos.org/man/3SOCKET/socketpair |
| 27 | /// [glibc]: https://sourceware.org/glibc/manual/latest/html_node/Socket-Pairs.html |
| 28 | #[inline ] |
| 29 | pub fn socketpair( |
| 30 | domain: AddressFamily, |
| 31 | type_: SocketType, |
| 32 | flags: SocketFlags, |
| 33 | protocol: Option<Protocol>, |
| 34 | ) -> io::Result<(OwnedFd, OwnedFd)> { |
| 35 | backend::net::syscalls::socketpair(family:domain, type_, flags, protocol) |
| 36 | } |
| 37 | |