Skip to content

Commit

Permalink
Fixup to e3b2201: fix a typo, minor code simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Feb 29, 2024
1 parent e3b2201 commit f536f77
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions examples/poem/local-server-with-browser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ async fn main() -> Result<(), std::io::Error> {

// To test port assignment, run two instances of this example at once.
//
// For ports <1024, running with administrator priveleges would be needed on
// Unix. For port 0, the OS would assign a port and we'd need to find out
// For ports <1024, running with administrator priveledges would be needed
// on Unix. For port 0, the OS would assign a port and we'd need to find out
// what that port's number is.
let (min_port, max_port) = (8080, 8085);
// Using 127.0.0.1 instead of 0.0.0.0 for security; a local server should
Expand All @@ -32,15 +32,13 @@ async fn main() -> Result<(), std::io::Error> {
if port > max_port {
return Err(error.unwrap());
}
let listener = TcpListener::bind(format!("{hostname}:{}", port));
let listener = TcpListener::bind(format!("{hostname}:{port}"));
match listener.into_acceptor().await {
Ok(a) => break a,
Err(err) => {
// Most likely, another application is bound to this port.
eprintln!("Couldn't bind to port {port}.");
error = Some(err)
}
Err(err) => error = Some(err),
};
// Most likely, another application is bound to this port.
eprintln!("Couldn't bind to port {port}.");
port += 1;
};

Expand Down

0 comments on commit f536f77

Please sign in to comment.