fix: disable SO_REUSEADDR & enable SO_EXCLUSIVEADDRUSE on Windows (#2128)

This commit is contained in:
Luna Yao
2026-04-24 18:37:34 +02:00
committed by GitHub
parent 4688ad74ad
commit b4666be696
5 changed files with 122 additions and 41 deletions
+1 -1
View File
@@ -423,7 +423,7 @@ fn setup_socket2_ext(
}
socket2_socket.set_nonblocking(true)?;
socket2_socket.set_reuse_address(true)?;
socket2_socket.set_reuse_address(!cfg!(target_os = "windows"))?;
if let Err(e) = socket2_socket.bind(&socket2::SockAddr::from(*bind_addr)) {
if bind_addr.is_ipv4() {
return Err(e.into());