mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-13 11:26:05 +00:00
Fix wake-on-lan failure on LAN after ARP cache expiration of target PC. Fixes #293
This commit is contained in:
@@ -33,7 +33,7 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
||||
+ (void) wakeHost:(TemporaryHost*)host {
|
||||
NSData* wolPayload = [WakeOnLanManager createPayload:host];
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const char* address;
|
||||
struct addrinfo hints, *res, *curr;
|
||||
|
||||
@@ -44,6 +44,8 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
||||
address = [host.externalAddress UTF8String];
|
||||
} else if (i == 2 && host.address != nil) {
|
||||
address = [host.address UTF8String];
|
||||
} else if (i == 3) {
|
||||
address = "255.255.255.255";
|
||||
} else {
|
||||
// Requested address wasn't present
|
||||
continue;
|
||||
@@ -63,6 +65,7 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
||||
// may be different address families.
|
||||
for (curr = res; curr != NULL; curr = curr->ai_next) {
|
||||
int wolSocket;
|
||||
int val;
|
||||
|
||||
wolSocket = socket(curr->ai_family, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (wolSocket < 0) {
|
||||
@@ -70,6 +73,9 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
||||
continue;
|
||||
}
|
||||
|
||||
val = 1;
|
||||
setsockopt(wolSocket, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val));
|
||||
|
||||
struct sockaddr_storage addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
memcpy(&addr, curr->ai_addr, curr->ai_addrlen);
|
||||
|
||||
Reference in New Issue
Block a user