diff options
| author | Steven Fackler <sfackler@gmail.com> | 2016-03-16 20:50:45 -0700 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2016-03-20 18:57:58 -0700 |
| commit | c0d989ed6b4b840a290a80ec0cdbc8edbce2ee57 (patch) | |
| tree | af07033b95415a5b27a5717fe4d9e2f3e3463d9d /src/libstd/sys/common/net.rs | |
| parent | 173676efdc8a9f1f2a86d37c08a104e2e505f9e4 (diff) | |
| download | rust-c0d989ed6b4b840a290a80ec0cdbc8edbce2ee57.tar.gz rust-c0d989ed6b4b840a290a80ec0cdbc8edbce2ee57.zip | |
Add unix socket support to the standard library
Diffstat (limited to 'src/libstd/sys/common/net.rs')
| -rw-r--r-- | src/libstd/sys/common/net.rs | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 42714feb921..3fa70d0ce4b 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -257,12 +257,7 @@ impl TcpStream { } pub fn take_error(&self) -> io::Result<Option<io::Error>> { - let raw: c_int = try!(getsockopt(&self.inner, c::SOL_SOCKET, c::SO_ERROR)); - if raw == 0 { - Ok(None) - } else { - Ok(Some(io::Error::from_raw_os_error(raw as i32))) - } + self.inner.take_error() } pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { @@ -367,12 +362,7 @@ impl TcpListener { } pub fn take_error(&self) -> io::Result<Option<io::Error>> { - let raw: c_int = try!(getsockopt(&self.inner, c::SOL_SOCKET, c::SO_ERROR)); - if raw == 0 { - Ok(None) - } else { - Ok(Some(io::Error::from_raw_os_error(raw as i32))) - } + self.inner.take_error() } pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { @@ -564,12 +554,7 @@ impl UdpSocket { } pub fn take_error(&self) -> io::Result<Option<io::Error>> { - let raw: c_int = try!(getsockopt(&self.inner, c::SOL_SOCKET, c::SO_ERROR)); - if raw == 0 { - Ok(None) - } else { - Ok(Some(io::Error::from_raw_os_error(raw as i32))) - } + self.inner.take_error() } pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { |
