|
| 1 | +//! illumos-specific networking functionality. |
| 2 | +
|
| 3 | +#![unstable(feature = "unix_socket_exclbind", issue = "none")] |
| 4 | + |
| 5 | +use crate::io; |
| 6 | +use crate::os::unix::net; |
| 7 | +use crate::sealed::Sealed; |
| 8 | +use crate::sys_common::AsInner; |
| 9 | + |
| 10 | +/// illumos-specific functionality for `AF_UNIX` sockets [`UnixDatagram`] |
| 11 | +/// and [`UnixStream`]. |
| 12 | +/// |
| 13 | +/// [`UnixDatagram`]: net::UnixDatagram |
| 14 | +/// [`UnixStream`]: net::UnixStream |
| 15 | +#[unstable(feature = "unix_socket_exclbind", issue = "none")] |
| 16 | +pub trait UnixSocketExt: Sealed { |
| 17 | + /// Enables exclusive binding on the socket. |
| 18 | + /// |
| 19 | + /// If true and if the socket had been set with `SO_REUSEADDR`, |
| 20 | + /// it neutralises its effect. |
| 21 | + /// See [`man 3 tcp`](https://docs.oracle.com/cd/E88353_01/html/E37843/setsockopt-3c.html) |
| 22 | + #[unstable(feature = "unix_socket_exclbind", issue = "none")] |
| 23 | + fn so_exclbind(&self, excl: bool) -> io::Result<()>; |
| 24 | + |
| 25 | + /// Get the bind exclusivity bind state of the socket. |
| 26 | + #[unstable(feature = "unix_socket_exclbind", issue = "none")] |
| 27 | + fn exclbind(&self) -> io::Result<bool>; |
| 28 | +} |
| 29 | + |
| 30 | +#[unstable(feature = "unix_socket_exclbind", issue = "none")] |
| 31 | +impl UnixSocketExt for net::UnixDatagram { |
| 32 | + fn exclbind(&self) -> io::Result<bool> { |
| 33 | + self.as_inner().exclbind() |
| 34 | + } |
| 35 | + |
| 36 | + fn so_exclbind(&self, excl: bool) -> io::Result<()> { |
| 37 | + self.as_inner().set_exclbind(excl) |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +#[unstable(feature = "unix_socket_exclbind", issue = "none")] |
| 42 | +impl UnixSocketExt for net::UnixStream { |
| 43 | + fn exclbind(&self) -> io::Result<bool> { |
| 44 | + self.as_inner().exclbind() |
| 45 | + } |
| 46 | + |
| 47 | + fn so_exclbind(&self, excl: bool) -> io::Result<()> { |
| 48 | + self.as_inner().set_exclbind(excl) |
| 49 | + } |
| 50 | +} |
0 commit comments