From 3e00456c6e60d814e7db2f4a936f09b66ab40e94 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Mon, 2 Sep 2024 10:43:50 +0200 Subject: [PATCH] Integrate #1322 --- zenoh/src/net/runtime/orchestrator.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/zenoh/src/net/runtime/orchestrator.rs b/zenoh/src/net/runtime/orchestrator.rs index fca109fc24..2e292f52ff 100644 --- a/zenoh/src/net/runtime/orchestrator.rs +++ b/zenoh/src/net/runtime/orchestrator.rs @@ -614,7 +614,7 @@ impl Runtime { ifaces: &[IpAddr], multicast_ttl: u32, ) -> ZResult { - let socket = match Socket::new(Domain::IPV4, Type::DGRAM, None) { + let socket = match Socket::new(Domain::for_address(*sockaddr), Type::DGRAM, None) { Ok(socket) => socket, Err(err) => { tracing::error!("Unable to create datagram socket: {}", err); @@ -704,21 +704,22 @@ impl Runtime { } pub fn bind_ucast_port(addr: IpAddr, multicast_ttl: u32) -> ZResult { - let socket = match Socket::new(Domain::IPV4, Type::DGRAM, None) { + let sockaddr = || SocketAddr::new(addr, 0); + let socket = match Socket::new(Domain::for_address(sockaddr()), Type::DGRAM, None) { Ok(socket) => socket, Err(err) => { tracing::warn!("Unable to create datagram socket: {}", err); bail!(err=> "Unable to create datagram socket"); } }; - match socket.bind(&SocketAddr::new(addr, 0).into()) { + match socket.bind(&sockaddr().into()) { Ok(()) => { #[allow(clippy::or_fun_call)] let local_addr = socket .local_addr() - .unwrap_or(SocketAddr::new(addr, 0).into()) + .unwrap_or(sockaddr().into()) .as_socket() - .unwrap_or(SocketAddr::new(addr, 0)); + .unwrap_or(sockaddr()); tracing::debug!("UDP port bound to {}", local_addr); } Err(err) => {