Skip to content

Commit

Permalink
g3-socket: fix build on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq-b committed Oct 23, 2024
1 parent d5adead commit 0fafac6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/g3-socket/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ g3-types.workspace = true
libc.workspace = true

[target.'cfg(windows)'.dependencies]
windows-sys.workspace = true
windows-sys = { workspace = true, features = ["Win32_Networking_WinSock"] }

[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt"] }
4 changes: 1 addition & 3 deletions lib/g3-socket/src/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ impl BindAddr {
#[cfg(any(target_os = "linux", target_os = "android"))]
set_bind_address_no_port(socket, true)?;
#[cfg(windows)]
set_reuse_unicastport(socket, true)?;
let _ = set_reuse_unicastport(socket, true);
let addr: SockAddr = SocketAddr::new(*ip, 0).into();
socket.bind(&addr)
}
#[cfg(any(target_os = "linux", target_os = "android"))]
BindAddr::Interface(name) => {
set_bind_address_no_port(socket, true)?;
#[cfg(windows)]
set_reuse_unicastport(socket, true)?;
socket.bind_device(Some(name.as_bytes()))
}
}
Expand Down

0 comments on commit 0fafac6

Please sign in to comment.