fix hermes lite enumeration issues and fix copy paste fail in network library

pull/1302/head
AlexandreRouma 2024-01-25 22:27:59 +01:00
rodzic 68bf2fc16f
commit 255988ee46
2 zmienionych plików z 7 dodań i 4 usunięć

Wyświetl plik

@ -390,7 +390,7 @@ namespace net {
#endif
if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &enable, sizeof(int)) < 0) {
closeSocket(s);
throw std::runtime_error("Could not configure socket");
throw std::runtime_error("Could not enable broadcast on socket");
return NULL;
}

Wyświetl plik

@ -205,8 +205,8 @@ namespace hermes {
}
std::vector<Info> discover() {
// TODO: Maybe try to instead detect on each interface as a work around for 0.0.0.0 not receiving anything?
auto sock = net::openudp("0.0.0.0", 1024);
// Open a UDP broadcast socket (TODO: Figure out why 255.255.255.255 doesn't work on windows with local = 0.0.0.0)
auto sock = net::openudp("255.255.255.255", 1024, "0.0.0.0", 0, true);
// Build discovery packet
uint8_t discoveryPkt[64];
@ -225,6 +225,7 @@ namespace hermes {
}
}
// Await all responses
std::vector<Info> devices;
while (true) {
// Wait for a response
@ -258,7 +259,9 @@ namespace hermes {
devices.push_back(info);
}
// Close broadcast socket
sock->close();
return devices;
}