Windows so_reuseport

This commit is contained in:
Igor Katson 2024-08-26 19:19:37 +01:00
parent aae78b57c7
commit c74d5f0866
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5

View file

@ -110,8 +110,12 @@ impl SsdpRunner {
let bind_addr = SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, UPNP_PORT);
let sock = socket2::Socket::new(socket2::Domain::IPV4, socket2::Type::DGRAM, None)
.context("error creating socket")?;
#[cfg(not(target_os = "windows"))]
sock.set_reuse_port(true)
.context("error setting SO_REUSEPORT")?;
#[cfg(target_os = "windows")]
sock.set_reuse_address(true)
.context("error setting SO_REUSEADDR")?;
trace!(addr=?bind_addr, "binding UDP");
sock.bind(&bind_addr.into())