MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / client

Function client

tests/event/epoll.rs:68–88  ·  view source on GitHub ↗
(ready: Arc<(Mutex<u16>, Condvar)>)

Source from the content-addressed store, hash-verified

66}
67
68fn client(ready: Arc<(Mutex<u16>, Condvar)>) {
69 let port = {
70 let (lock, cvar) = &*ready;
71 let mut port = lock.lock().unwrap();
72 while *port == 0 {
73 port = cvar.wait(port).unwrap();
74 }
75 *port
76 };
77
78 let addr = SocketAddrV4::new(Ipv4Addr::LOCALHOST, port);
79 let mut buffer = vec![0; BUFFER_SIZE];
80
81 for _ in 0..16 {
82 let data_socket = socket(AddressFamily::INET, SocketType::STREAM, None).unwrap();
83 connect(&data_socket, &addr).unwrap();
84
85 let nread = read(&data_socket, &mut buffer).unwrap();
86 assert_eq!(String::from_utf8_lossy(&buffer[..nread]), "hello\n");
87 }
88}
89
90#[test]
91fn test_epoll() {

Callers 1

test_epollFunction · 0.70

Calls 3

socketFunction · 0.50
connectFunction · 0.50
readFunction · 0.50

Tested by 1

test_epollFunction · 0.56