Skip to content

Commit

Permalink
set reuse_address
Browse files Browse the repository at this point in the history
  • Loading branch information
vnt-dev committed Mar 20, 2024
1 parent e27c004 commit 01fdcff
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ async fn main() {
let socket = socket2::Socket::new(socket2::Domain::IPV6, socket2::Type::DGRAM, None).unwrap();
socket.set_only_v6(false).unwrap();
socket.set_nonblocking(true).unwrap();
socket.set_reuse_address(true).unwrap();
match socket.bind(&address.into()) {
Ok(_) => {}
Err(e) => {
Expand All @@ -223,6 +224,7 @@ async fn main() {
println!("监听udp端口: {:?}", udp.local_addr().unwrap());
let socket = socket2::Socket::new(socket2::Domain::IPV6, socket2::Type::STREAM, None).unwrap();
socket.set_only_v6(false).unwrap();
socket.set_reuse_address(true).unwrap();
match socket.bind(&address.into()) {
Ok(_) => {}
Err(e) => {
Expand Down

0 comments on commit 01fdcff

Please sign in to comment.