Fix wake-on-lan failure on LAN after ARP cache expiration of target PC

This commit is contained in:
Cameron Gutman 2018-01-19 20:00:55 -08:00
parent 6eed8408fc
commit 7a8166ec09

View File

@ -22,8 +22,12 @@ public class WakeOnLanSender {
boolean sentWolPacket = false;
try {
// Try all resolved remote and local addresses
for (String unresolvedAddress : new String[] {computer.localAddress, computer.remoteAddress}) {
// Try all resolved remote and local addresses and IPv4 broadcast address.
// The broadcast address is required to avoid stale ARP cache entries
// making the sleeping machine unreachable.
for (String unresolvedAddress : new String[] {
computer.localAddress, computer.remoteAddress, "255.255.255.255"
}) {
try {
for (InetAddress resolvedAddress : InetAddress.getAllByName(unresolvedAddress)) {
// Try all the ports for each resolved address