Skip to content

Commit

Permalink
Integrate #1322
Browse files Browse the repository at this point in the history
  • Loading branch information
Mallets committed Sep 2, 2024
1 parent 3ccb1bb commit 3e00456
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions zenoh/src/net/runtime/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl Runtime {
ifaces: &[IpAddr],
multicast_ttl: u32,
) -> ZResult<UdpSocket> {
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);
Expand Down Expand Up @@ -704,21 +704,22 @@ impl Runtime {
}

pub fn bind_ucast_port(addr: IpAddr, multicast_ttl: u32) -> ZResult<UdpSocket> {
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) => {
Expand Down

0 comments on commit 3e00456

Please sign in to comment.