diff options
| author | Steven Fackler <sfackler@gmail.com> | 2016-03-02 22:05:14 -0800 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2016-03-02 22:05:14 -0800 |
| commit | 631fa2b8c059ecf22b69941d700d9c9fce0ed47f (patch) | |
| tree | aa02452a17f9fb8df9dd19e4f957d55a5ba0d76c /src/libstd | |
| parent | 728d9115e894bd3c8fc3ae03230ea46f85467c04 (diff) | |
| download | rust-631fa2b8c059ecf22b69941d700d9c9fce0ed47f.tar.gz rust-631fa2b8c059ecf22b69941d700d9c9fce0ed47f.zip | |
Fix comments and OSX build
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/net/tcp.rs | 11 | ||||
| -rw-r--r-- | src/libstd/sys/common/net.rs | 24 |
2 files changed, 30 insertions, 5 deletions
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 0073b8f119a..f8e3b58bb3e 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -1152,9 +1152,16 @@ mod tests { t!(listener.set_nonblocking(true)); t!(listener.set_nonblocking(false)); - let stream = t!(TcpStream::connect(&("localhost", addr.port()))); + let mut stream = t!(TcpStream::connect(&("localhost", addr.port()))); - t!(stream.set_nonblocking(true)); t!(stream.set_nonblocking(false)); + t!(stream.set_nonblocking(true)); + + let mut buf = [0]; + match stream.read(&mut buf) { + Ok(_) => panic!("expected error"), + Err(ref e) if e.kind() == ErrorKind::WouldBlock => {} + Err(e) => panic!("unexpected error {}", e), + } } } diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index c8738fd1ba5..d16380a96b2 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -25,6 +25,23 @@ use sys::net::netc as c; use sys_common::{AsInner, FromInner, IntoInner}; use time::Duration; +#[cfg(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos", + target_os = "openbsd"))] +use sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP; +#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos", + target_os = "openbsd")))] +use sys::net::netc::IPV6_ADD_MEMBERSHIP; +#[cfg(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos", + target_os = "openbsd"))] +use sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP; +#[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", + target_os = "ios", target_os = "macos", + target_os = "openbsd")))] +use sys::net::netc::IPV6_DROP_MEMBERSHIP; + //////////////////////////////////////////////////////////////////////////////// // sockaddr and misc bindings //////////////////////////////////////////////////////////////////////////////// @@ -40,7 +57,8 @@ pub fn setsockopt<T>(sock: &Socket, opt: c_int, val: c_int, } pub fn getsockopt<T: Copy>(sock: &Socket, opt: c_int, - val: c_int) -> io::Result<T> { unsafe { + val: c_int) -> io::Result<T> { + unsafe { let mut slot: T = mem::zeroed(); let mut len = mem::size_of::<T>() as c::socklen_t; try!(cvt(c::getsockopt(*sock.as_inner(), opt, val, @@ -532,7 +550,7 @@ impl UdpSocket { ipv6mr_multiaddr: *multiaddr.as_inner(), ipv6mr_interface: to_ipv6mr_interface(interface), }; - setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_ADD_MEMBERSHIP, mreq) + setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, mreq) } pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) @@ -550,7 +568,7 @@ impl UdpSocket { ipv6mr_multiaddr: *multiaddr.as_inner(), ipv6mr_interface: to_ipv6mr_interface(interface), }; - setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_DROP_MEMBERSHIP, mreq) + setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, mreq) } pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { |
