Fix connection issue when several network interfaces are connected on the same network

This commit is contained in:
Guillaume Meunier
2025-04-27 16:03:27 +02:00
parent 0ce7662f58
commit 5cf1697c5d
3 changed files with 4 additions and 9 deletions
+2 -7
View File
@@ -80,14 +80,9 @@ wivrn::UDP::UDP(int fd)
this->fd = fd;
}
void wivrn::UDP::bind(int port)
void wivrn::UDP::bind(sockaddr_in6 address)
{
sockaddr_in6 bind_addr{};
bind_addr.sin6_family = AF_INET6;
bind_addr.sin6_addr = IN6ADDR_ANY_INIT;
bind_addr.sin6_port = htons(port);
if (::bind(fd, (sockaddr *)&bind_addr, sizeof(bind_addr)) < 0)
if (::bind(fd, (sockaddr *)&address, sizeof(address)) < 0)
throw std::system_error{errno, std::generic_category()};
}