WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/cmd/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ pub fn execute(args: &ArgMatches) -> Result<()> {
update_config(&mut book);
book.build()?;

let listener = std::net::TcpListener::bind(&address);
if listener.is_err() {
return Err(anyhow::anyhow!("Unable to bind to address: {} (It is either a protected port or it is used already. Try to another port or use --port 0 to select a random port. ", address).into());
}
drop(listener);

let sockaddr: SocketAddr = address
.to_socket_addrs()?
.next()
Expand Down