From c0d989ed6b4b840a290a80ec0cdbc8edbce2ee57 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 16 Mar 2016 20:50:45 -0700 Subject: Add unix socket support to the standard library --- src/libstd/sys/windows/net.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libstd/sys/windows') diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs index bb3c79c5a84..3a2f06418cf 100644 --- a/src/libstd/sys/windows/net.rs +++ b/src/libstd/sys/windows/net.rs @@ -214,6 +214,15 @@ impl Socket { let raw: c::BYTE = try!(net::getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)); Ok(raw != 0) } + + pub fn take_error(&self) -> io::Result> { + let raw: c_int = try!(net::getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)); + if raw == 0 { + Ok(None) + } else { + Ok(Some(io::Error::from_raw_os_error(raw as i32))) + } + } } #[unstable(reason = "not public", issue = "0", feature = "fd_read")] -- cgit 1.4.1-3-g733a5