about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-03-12 17:04:34 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-03-13 15:52:37 -0700
commita63deeb3d32fc21f36d484d62a3ea1d3d0c82500 (patch)
tree09421405ec3085de6217dfdef14cc119fd6da596 /src/libstd/io
parent3316a0e6b2ad9352bab58e7c046ef3d212411d82 (diff)
downloadrust-a63deeb3d32fc21f36d484d62a3ea1d3d0c82500.tar.gz
rust-a63deeb3d32fc21f36d484d62a3ea1d3d0c82500.zip
io: Bind to shutdown() for TCP streams
This is something that is plausibly useful, and is provided by libuv. This is
not currently surfaced as part of the `TcpStream` type, but it may possibly
appear in the future. For now only the raw functionality is provided through the
Rtio objects.
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/net/tcp.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs
index 53129f3df9b..95be3add0db 100644
--- a/src/libstd/io/net/tcp.rs
+++ b/src/libstd/io/net/tcp.rs
@@ -751,5 +751,23 @@ mod test {
 
         p.recv();
     })
+
+    iotest!(fn shutdown_smoke() {
+        use rt::rtio::RtioTcpStream;
+
+        let addr = next_test_ip4();
+        let a = TcpListener::bind(addr).unwrap().listen();
+        spawn(proc() {
+            let mut a = a;
+            let mut c = a.accept().unwrap();
+            assert_eq!(c.read_to_end(), Ok(~[]));
+            c.write([1]).unwrap();
+        });
+
+        let mut s = TcpStream::connect(addr).unwrap();
+        assert!(s.obj.close_write().is_ok());
+        assert!(s.write([1]).is_err());
+        assert_eq!(s.read_to_end(), Ok(~[1]));
+    })
 }