1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use socketpair;
use ;
use LocalProtocol;
use io;
/// Returns a pair of connected UNIX domain sockets.
///
/// # Example
///
/// ```
/// use std::thread;
/// use asyncio::{IoContext, Stream};
/// use asyncio::local::{LocalStream, LocalStreamSocket, connect_pair};
///
/// const MESSAGE: &'static str = "hello";
///
/// let ctx = &IoContext::new().unwrap();
/// let (tx, rx) = connect_pair(ctx, LocalStream).unwrap();
///
/// let thrd = thread::spawn(move|| {
/// let mut buf = [0; 32];
/// let len = rx.read_some(&mut buf).unwrap();
/// assert_eq!(len, MESSAGE.len());
/// assert_eq!(&buf[..len], MESSAGE.as_bytes());
/// });
///
/// tx.write_some(MESSAGE.as_bytes()).unwrap();
/// thrd.join().unwrap();
/// ```