Skip to content

Commit 255988e

Browse files
fix hermes lite enumeration issues and fix copy paste fail in network library
1 parent 68bf2fc commit 255988e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

core/src/utils/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ namespace net {
390390
#endif
391391
if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &enable, sizeof(int)) < 0) {
392392
closeSocket(s);
393-
throw std::runtime_error("Could not configure socket");
393+
throw std::runtime_error("Could not enable broadcast on socket");
394394
return NULL;
395395
}
396396

source_modules/hermes_source/src/hermes.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ namespace hermes {
205205
}
206206

207207
std::vector<Info> discover() {
208-
// TODO: Maybe try to instead detect on each interface as a work around for 0.0.0.0 not receiving anything?
209-
auto sock = net::openudp("0.0.0.0", 1024);
208+
// Open a UDP broadcast socket (TODO: Figure out why 255.255.255.255 doesn't work on windows with local = 0.0.0.0)
209+
auto sock = net::openudp("255.255.255.255", 1024, "0.0.0.0", 0, true);
210210

211211
// Build discovery packet
212212
uint8_t discoveryPkt[64];
@@ -225,6 +225,7 @@ namespace hermes {
225225
}
226226
}
227227

228+
// Await all responses
228229
std::vector<Info> devices;
229230
while (true) {
230231
// Wait for a response
@@ -258,7 +259,9 @@ namespace hermes {
258259

259260
devices.push_back(info);
260261
}
261-
262+
263+
// Close broadcast socket
264+
sock->close();
262265

263266
return devices;
264267
}

0 commit comments

Comments
 (0)