Skip to content

Commit e16707f

Browse files
committed
Test incoming connection on localhost
1 parent 3d80d40 commit e16707f

File tree

1 file changed

+7
-3
lines changed
  • fortanix-vme/aws-nitro-enclaves/tests/incoming_connection/src

1 file changed

+7
-3
lines changed

fortanix-vme/aws-nitro-enclaves/tests/incoming_connection/src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ use std::io::{ErrorKind, Read, Write};
33
use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpListener, TcpStream};
44
use std::os::unix::io::{AsRawFd, FromRawFd};
55

6-
fn server_run() {
6+
fn server_run(run: u32) {
77
println!("Bind TCP socket to port 3400");
8-
let listener = TcpListener::bind("127.0.0.1:3400").expect("Bind failed");
8+
let listener = if run == 1 {
9+
TcpListener::bind("127.0.0.1:3400").expect("Bind failed")
10+
} else {
11+
TcpListener::bind("localhost:3400").expect("Bind failed")
12+
};
913
assert_eq!(listener.local_addr().unwrap(), SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 3400));
1014

1115
let fd = listener.as_raw_fd();
@@ -49,7 +53,7 @@ fn server_run() {
4953
fn main() {
5054
for run in 1..=2 {
5155
println!("Server run #{}", run);
52-
server_run()
56+
server_run(run)
5357
}
5458
println!("Bye bye");
5559
}

0 commit comments

Comments
 (0)