diff options
| author | David Carlier <devnexen@gmail.com> | 2024-04-04 23:36:13 +0100 |
|---|---|---|
| committer | David Carlier <devnexen@gmail.com> | 2025-06-10 19:44:45 +0100 |
| commit | 1bbabb7ff744f18edaf3da30f841a287de2077d6 (patch) | |
| tree | a79f6c4bea563dfec5ed5849c3c655bc521a1765 /library/std/src/sys/net/connection/socket/unix.rs | |
| parent | c6a955468b025dbe3d1de3e8f3e30496d1fb7f40 (diff) | |
| download | rust-1bbabb7ff744f18edaf3da30f841a287de2077d6.tar.gz rust-1bbabb7ff744f18edaf3da30f841a287de2077d6.zip | |
std::net: adding `unix_socket_exclbind` feature for solaris/illumos.
allows to have a tigher control over the binding exclusivness of the socket.
Diffstat (limited to 'library/std/src/sys/net/connection/socket/unix.rs')
| -rw-r--r-- | library/std/src/sys/net/connection/socket/unix.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs index b35d5d2aa84..37d4078b963 100644 --- a/library/std/src/sys/net/connection/socket/unix.rs +++ b/library/std/src/sys/net/connection/socket/unix.rs @@ -514,6 +514,21 @@ impl Socket { Ok(name) } + #[cfg(any(target_os = "solaris", target_os = "illumos"))] + pub fn set_exclbind(&self, excl: bool) -> io::Result<()> { + // not yet on libc crate + const SO_EXCLBIND: i32 = 0x1015; + setsockopt(self, libc::SOL_SOCKET, SO_EXCLBIND, excl) + } + + #[cfg(any(target_os = "solaris", target_os = "illumos"))] + pub fn exclbind(&self) -> io::Result<bool> { + // not yet on libc crate + const SO_EXCLBIND: i32 = 0x1015; + let raw: c_int = getsockopt(self, libc::SOL_SOCKET, SO_EXCLBIND)?; + Ok(raw != 0) + } + #[cfg(any(target_os = "android", target_os = "linux",))] pub fn set_passcred(&self, passcred: bool) -> io::Result<()> { setsockopt(self, libc::SOL_SOCKET, libc::SO_PASSCRED, passcred as libc::c_int) |
