File tree 1 file changed +13
-0
lines changed
arduino-core/src/cc/arduino/packages/discoverers/network
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 31
31
32
32
import javax .jmdns .NetworkTopologyDiscovery ;
33
33
import java .net .InetAddress ;
34
+ import java .net .NetworkInterface ;
35
+ import java .net .SocketException ;
34
36
import java .util .*;
35
37
36
38
public class NetworkChecker extends TimerTask {
@@ -53,6 +55,9 @@ public void start(Timer timer) {
53
55
54
56
@ Override
55
57
public void run () {
58
+ if (!hasNetworkInterfaces ()) {
59
+ return ;
60
+ }
56
61
try {
57
62
InetAddress [] curentAddresses = topology .getInetAddresses ();
58
63
Set <InetAddress > current = new HashSet <>(curentAddresses .length );
@@ -68,4 +73,12 @@ public void run() {
68
73
e .printStackTrace ();
69
74
}
70
75
}
76
+
77
+ private boolean hasNetworkInterfaces () {
78
+ try {
79
+ return NetworkInterface .getNetworkInterfaces () != null ;
80
+ } catch (SocketException e ) {
81
+ return false ;
82
+ }
83
+ }
71
84
}
You can’t perform that action at this time.
0 commit comments