Skip to content

getting the port of a random port binding #679

Answered by chrislearn
davehorner asked this question in Q&A
Discussion options

You must be logged in to vote
let listener = TcpListener::new(&addr);
 let acceptor = listener.bind().await;
 let bound_addr = acceptor.local_addr();
 let server = Server::new(acceptor);

You should not ask so basic question here!

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@davehorner
Comment options

@chrislearn
Comment options

Comment options

You must be logged in to vote
5 replies
@chrislearn
Comment options

@davehorner
Comment options

@davehorner
Comment options

@chrislearn
Comment options

Answer selected by davehorner
@davehorner
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants