Skip to content

Commit b02e958

Browse files
committed
Addressing reviewer comments
1 parent fbb7f73 commit b02e958

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

fortanix-vme/aws-nitro-enclaves/tests/incoming_connection/out.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
Server run #1
1+
Running server on 127.0.0.1:3400
22
Bind TCP socket to port 3400
33
Listening for incoming connections...
44
Waiting for connection 1
55
Connection 1: Connected
66
Waiting for connection 2
77
Connection 2: Connected
8-
Server run #2
8+
Running server on localhost:3400
99
Bind TCP socket to port 3400
1010
Listening for incoming connections...
1111
Waiting for connection 1

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
#![feature(io_error_uncategorized)]
22
use std::io::{ErrorKind, Read, Write};
3-
use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpListener, TcpStream};
3+
use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpListener, TcpStream, ToSocketAddrs};
44
use std::os::unix::io::{AsRawFd, FromRawFd};
55

6-
fn server_run(run: u32) {
6+
fn server_run<A: ToSocketAddrs>(addr: A) {
77
println!("Bind TCP socket to port 3400");
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-
};
8+
let listener = TcpListener::bind(addr).expect("Bind failed");
139
assert_eq!(listener.local_addr().unwrap(), SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 3400));
1410

1511
let fd = listener.as_raw_fd();
@@ -51,9 +47,9 @@ fn server_run(run: u32) {
5147
}
5248

5349
fn main() {
54-
for run in 1..=2 {
55-
println!("Server run #{}", run);
56-
server_run(run)
50+
for addr in &["127.0.0.1:3400", "localhost:3400"] {
51+
println!("Running server on {}", addr);
52+
server_run(addr)
5753
}
5854
println!("Bye bye");
5955
}

0 commit comments

Comments
 (0)