| 43 | } |
| 44 | |
| 45 | fn 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] |
| 69 | fn test_v6() { |