diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-06-28 22:05:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-28 22:05:27 +0200 |
| commit | 7394bd5fc220c5bbf7b7dfde573c2e45d7825333 (patch) | |
| tree | afa31ab662e58a55c78cf9a1be037c22c779a89e /library/std/src/sys/net/connection/socket/unix.rs | |
| parent | 7ba34c704529e7fcab80130c3fe40efe415d61b5 (diff) | |
| parent | 1bbabb7ff744f18edaf3da30f841a287de2077d6 (diff) | |
| download | rust-7394bd5fc220c5bbf7b7dfde573c2e45d7825333.tar.gz rust-7394bd5fc220c5bbf7b7dfde573c2e45d7825333.zip | |
Rollup merge of #123476 - devnexen:std_net_solaris_exclbind, r=Mark-Simulacrum
std::net: adding `unix_socket_exclbind` feature for solaris/illumos. allows to have a tigher control over the binding exclusivness of the socket. ACP: https://github.com/rust-lang/libs-team/issues/366
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 b2a4961c3c5..cc111f3521b 100644 --- a/library/std/src/sys/net/connection/socket/unix.rs +++ b/library/std/src/sys/net/connection/socket/unix.rs @@ -522,6 +522,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) |
