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

Function client

tests/net/v6.rs:45–66  ·  view source on GitHub ↗
(ready: Arc<(Mutex<u16>, Condvar)>)

Source from the content-addressed store, hash-verified

43}
44
45fn client(ready: Arc<(Mutex<u16>, Condvar)>) {
46 let port = {
47 let (lock, cvar) = &*ready;
48 let mut port = lock.lock().unwrap();
49 while *port == 0 {
50 port = cvar.wait(port).unwrap();
51 }
52 *port
53 };
54
55 let addr = SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), port, 0, 0);
56 let mut buffer = vec![0; BUFFER_SIZE];
57
58 let data_socket = socket(AddressFamily::INET6, SocketType::STREAM, None).unwrap();
59 connect(&data_socket, &addr).unwrap();
60
61 send(&data_socket, b"hello, world", SendFlags::empty()).unwrap();
62
63 let (nread, actual) = recv(&data_socket, &mut buffer, RecvFlags::empty()).unwrap();
64 assert_eq!(String::from_utf8_lossy(&buffer[..nread]), "goodnight, moon");
65 assert_eq!(actual, nread);
66}
67
68#[test]
69fn test_v6() {

Callers 3

test_v6Function · 0.70
test_v6_msgFunction · 0.70
test_v6_sendmmsgFunction · 0.70

Calls 8

as_anyMethod · 0.80
socketFunction · 0.50
connectFunction · 0.50
sendFunction · 0.50
recvFunction · 0.50
sendmsgFunction · 0.50
recvmsgFunction · 0.50
sendmmsgFunction · 0.50

Tested by 3

test_v6Function · 0.56
test_v6_msgFunction · 0.56
test_v6_sendmmsgFunction · 0.56