Skip to content

Commit 44b5910

Browse files
authored
protocol/mdns: Use SO_REUSEPORT for the mDNS socket (#68)
On macOS, failure to use `SO_REUSEPORT` would result in mDNS not being able to bind to the socket, causing `Litep2p::new()` to exit with `EADDRINUSE`.
1 parent fd0bdfb commit 44b5910

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/protocol/mdns.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ impl Mdns {
128128
) -> crate::Result<Self> {
129129
let socket = Socket::new(Domain::IPV4, Type::DGRAM, Some(Protocol::UDP))?;
130130
socket.set_reuse_address(true)?;
131-
// TODO: fix
132-
// #[cfg(unix)]
133-
// socket.set_reuse_port(true)?;
131+
#[cfg(unix)]
132+
socket.set_reuse_port(true)?;
134133
socket.bind(
135134
&SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), IPV4_MULTICAST_PORT).into(),
136135
)?;

0 commit comments

Comments
 (0)