From 3a1a50620397b347db105e65b3cab650c2c7bb72 Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Mon, 2 Nov 2020 18:45:36 -0800 Subject: Upgrade rust/crates/mio to 0.7.5 Test: make Change-Id: I0b3424bb3d27a0db04cd91b8573fca44e311c491 --- src/net/tcp/socket.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/net/tcp/socket.rs') 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 { + 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 { + sys::tcp::get_reuseport(self.sys) + } + /// Sets the value of `SO_LINGER` on this socket. pub fn set_linger(&self, dur: Option) -> 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 { + sys::tcp::get_localaddr(self.sys) + } } impl Drop for TcpSocket { -- cgit v1.2.3