Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ categories = ["network-programming"]
description = "mDNS Service Discovery library with no async runtime dependency"

[features]
reuseport = []
async = ["flume/async"]
logging = ["log"]
default = ["reuseport", "async", "logging"]
default = ["async", "logging"]

[dependencies]
fastrand = "2.3"
Expand Down
10 changes: 7 additions & 3 deletions src/service_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,13 @@ fn new_socket(addr: SocketAddr, non_block: bool) -> Result<PktInfoUdpSocket> {

fd.set_reuse_address(true)
.map_err(|e| e_fmt!("set ReuseAddr failed: {}", e))?;
#[cfg(all(unix, feature = "reuseport"))] // this is currently restricted to Unix's in socket2
fd.set_reuse_port(true)
.map_err(|e| e_fmt!("set ReusePort failed: {}", e))?;
#[cfg(unix)]
if let Err(e) = fd.set_reuse_port(true) {
debug!(
"SO_REUSEPORT is not supported, continuing without it: {}",
e
);
}

if non_block {
fd.set_nonblocking(true)
Expand Down