Skip to content

Commit 10d20f5

Browse files
committed
Test listener info
1 parent 6191069 commit 10d20f5

File tree

1 file changed

+6
-1
lines changed
  • fortanix-vme/tests/incoming_connection/src

1 file changed

+6
-1
lines changed

fortanix-vme/tests/incoming_connection/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpListener};
21
use std::io::{Read, Write};
2+
use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpListener};
3+
use std::os::unix::io::{AsRawFd, FromRawFd};
34

45
fn server_run() {
56
println!("Bind TCP socket to port 3400");
67
let listener = TcpListener::bind("127.0.0.1:3400").expect("Bind failed");
78
assert_eq!(listener.local_addr().unwrap(), SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 3400));
89

10+
let fd = listener.as_raw_fd();
11+
let listener1 = unsafe { TcpListener::from_raw_fd(fd) };
12+
assert_eq!(listener1.local_addr().unwrap(), SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 3400));
13+
914
println!("Listening for incoming connections...");
1015
for id in 1..3 {
1116
println!("Waiting for connection {}", id);

0 commit comments

Comments
 (0)