Skip to content

Commit

Permalink
Update client.rs
Browse files Browse the repository at this point in the history
Fix the issue that the connection creation fails when the network changes
  • Loading branch information
dev4u authored Mar 14, 2022
1 parent feaf0cd commit 3c231ab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ async fn main() -> Result<()> {

while let Ok((inbound, _)) = listener.accept().await {
info!("connection incoming");
let socket = if cfg!(target_os = "windows") {
std::net::UdpSocket::bind("0.0.0.0:0").unwrap()
} else {
std::net::UdpSocket::bind("[::]:0").unwrap()
};
endpoint.rebind(socket)?;

let remote = Arc::clone(&remote);
let host = Arc::clone(&host);
Expand Down

0 comments on commit 3c231ab

Please sign in to comment.