-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
std::net: adding
unix_socket_exclbind
feature for solaris/illumos.
allows to have a tigher control over the binding exclusivness of the socket.
- Loading branch information
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
#![stable(feature = "raw_ext", since = "1.1.0")] | ||
|
||
pub mod fs; | ||
pub mod net; | ||
pub mod raw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//! illumos-specific networking functionality. | ||
#![unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
|
||
use crate::io; | ||
use crate::os::unix::net; | ||
use crate::sealed::Sealed; | ||
use crate::sys_common::AsInner; | ||
|
||
/// illumos-specific functionality for `AF_UNIX` sockets [`UnixDatagram`] | ||
/// and [`UnixStream`]. | ||
/// | ||
/// [`UnixDatagram`]: net::UnixDatagram | ||
/// [`UnixStream`]: net::UnixStream | ||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
pub trait UnixSocketExt: Sealed { | ||
/// Enables exclusive binding on the socket. | ||
/// | ||
/// If true and if the socket had been set with `SO_REUSEADDR`, | ||
/// it neutralises its effect. | ||
/// See [`man 3 tcp`](https://docs.oracle.com/cd/E88353_01/html/E37843/setsockopt-3c.html) | ||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
fn so_exclbind(&self, excl: bool) -> io::Result<()>; | ||
|
||
/// Get the bind exclusivity bind state of the socket. | ||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
fn exclbind(&self) -> io::Result<bool>; | ||
} | ||
|
||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
impl UnixSocketExt for net::UnixDatagram { | ||
fn exclbind(&self) -> io::Result<bool> { | ||
self.as_inner().exclbind() | ||
} | ||
|
||
fn so_exclbind(&self, excl: bool) -> io::Result<()> { | ||
self.as_inner().set_exclbind(excl) | ||
} | ||
} | ||
|
||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
impl UnixSocketExt for net::UnixStream { | ||
fn exclbind(&self) -> io::Result<bool> { | ||
self.as_inner().exclbind() | ||
} | ||
|
||
fn so_exclbind(&self, excl: bool) -> io::Result<()> { | ||
self.as_inner().set_exclbind(excl) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
#![stable(feature = "raw_ext", since = "1.1.0")] | ||
|
||
pub mod fs; | ||
pub mod net; | ||
pub mod raw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//! solaris-specific networking functionality. | ||
#![unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
|
||
use crate::io; | ||
use crate::os::unix::net; | ||
use crate::sealed::Sealed; | ||
use crate::sys_common::AsInner; | ||
|
||
/// solaris-specific functionality for `AF_UNIX` sockets [`UnixDatagram`] | ||
/// and [`UnixStream`]. | ||
/// | ||
/// [`UnixDatagram`]: net::UnixDatagram | ||
/// [`UnixStream`]: net::UnixStream | ||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
pub trait UnixSocketExt: Sealed { | ||
/// Enables exclusive binding on the socket. | ||
/// | ||
/// If true and if the socket had been set with `SO_REUSEADDR`, | ||
/// it neutralises its effect. | ||
/// See [`man 3 tcp`](https://docs.oracle.com/cd/E88353_01/html/E37843/setsockopt-3c.html) | ||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
fn so_exclbind(&self, excl: bool) -> io::Result<()>; | ||
|
||
/// Get the bind exclusivity bind state of the socket. | ||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
fn exclbind(&self) -> io::Result<bool>; | ||
} | ||
|
||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
impl UnixSocketExt for net::UnixDatagram { | ||
fn exclbind(&self) -> io::Result<bool> { | ||
self.as_inner().exclbind() | ||
} | ||
|
||
fn so_exclbind(&self, excl: bool) -> io::Result<()> { | ||
self.as_inner().set_exclbind(excl) | ||
} | ||
} | ||
|
||
#[unstable(feature = "unix_socket_exclbind", issue = "123481")] | ||
impl UnixSocketExt for net::UnixStream { | ||
fn exclbind(&self) -> io::Result<bool> { | ||
self.as_inner().exclbind() | ||
} | ||
|
||
fn so_exclbind(&self, excl: bool) -> io::Result<()> { | ||
self.as_inner().set_exclbind(excl) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters