aboutsummaryrefslogtreecommitdiff
path: root/src/net/tcp/socket.rs
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-11-02 18:45:36 -0800
committerHaibo Huang <hhb@google.com>2020-11-02 18:45:36 -0800
commit3a1a50620397b347db105e65b3cab650c2c7bb72 (patch)
treefe408064c79f43f6575f398a4a33a4f9c4d69adf /src/net/tcp/socket.rs
parent547d80671d6fbd3df9883d1670a6700eda533536 (diff)
downloadmio-3a1a50620397b347db105e65b3cab650c2c7bb72.tar.gz
Upgrade rust/crates/mio to 0.7.5
Test: make Change-Id: I0b3424bb3d27a0db04cd91b8573fca44e311c491
Diffstat (limited to 'src/net/tcp/socket.rs')
-rw-r--r--src/net/tcp/socket.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/net/tcp/socket.rs b/src/net/tcp/socket.rs
index a91f665..f3e27c3 100644
--- a/src/net/tcp/socket.rs
+++ b/src/net/tcp/socket.rs
@@ -82,10 +82,36 @@ impl TcpSocket {
sys::tcp::set_reuseaddr(self.sys, reuseaddr)
}
+ /// Get the value of `SO_REUSEADDR` set on this socket.
+ pub fn get_reuseaddr(&self) -> io::Result<bool> {
+ sys::tcp::get_reuseaddr(self.sys)
+ }
+
+ /// Sets the value of `SO_REUSEPORT` on this socket.
+ /// Only supported available in unix
+ #[cfg(all(unix, not(any(target_os = "solaris", target_os = "illumos"))))]
+ pub fn set_reuseport(&self, reuseport: bool) -> io::Result<()> {
+ sys::tcp::set_reuseport(self.sys, reuseport)
+ }
+
+ /// Get the value of `SO_REUSEPORT` set on this socket.
+ /// Only supported available in unix
+ #[cfg(all(unix, not(any(target_os = "solaris", target_os = "illumos"))))]
+ pub fn get_reuseport(&self) -> io::Result<bool> {
+ sys::tcp::get_reuseport(self.sys)
+ }
+
/// Sets the value of `SO_LINGER` on this socket.
pub fn set_linger(&self, dur: Option<Duration>) -> io::Result<()> {
sys::tcp::set_linger(self.sys, dur)
}
+
+ /// Returns the local address of this socket
+ ///
+ /// Will return `Err` result in windows if called before calling `bind`
+ pub fn get_localaddr(&self) -> io::Result<SocketAddr> {
+ sys::tcp::get_localaddr(self.sys)
+ }
}
impl Drop for TcpSocket {