summaryrefslogtreecommitdiff
path: root/test/sys/test_socket.rs
diff options
context:
space:
mode:
authorFlorian Hartwig <florian.j.hartwig@gmail.com>2015-04-11 23:51:13 +0200
committerFlorian Hartwig <florian.j.hartwig@gmail.com>2015-04-11 23:51:13 +0200
commite3d86a9ccd59c8332116041e5e32473d7835f43a (patch)
tree6950129ed4ed97aeacb1e126ccd520ca3f4be7d1 /test/sys/test_socket.rs
parent9b0a534962f3a2852491a3b0bc4d4e857f2a1382 (diff)
downloadnix-e3d86a9ccd59c8332116041e5e32473d7835f43a.zip
Add socketpair
Diffstat (limited to 'test/sys/test_socket.rs')
-rw-r--r--test/sys/test_socket.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs
index 1983e7b5..e8cb4bed 100644
--- a/test/sys/test_socket.rs
+++ b/test/sys/test_socket.rs
@@ -48,3 +48,18 @@ pub fn test_getsockname() {
assert_eq!(addr, res.to_str());
}
+
+#[test]
+pub fn test_socketpair() {
+ use nix::unistd::{read, write};
+ use nix::sys::socket::{socketpair, AddressFamily, SockType, SockFlag};
+
+ let (fd1, fd2) = socketpair(AddressFamily::Unix, SockType::Stream, 0,
+ SockFlag::empty())
+ .unwrap();
+ write(fd1, b"hello").unwrap();
+ let mut buf = [0;5];
+ read(fd2, &mut buf).unwrap();
+
+ assert_eq!(&buf[..], b"hello");
+}