File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
arduino-core/src/cc/arduino/packages/discoverers/network Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 3131
3232import javax .jmdns .NetworkTopologyDiscovery ;
3333import java .net .InetAddress ;
34+ import java .net .NetworkInterface ;
35+ import java .net .SocketException ;
3436import java .util .*;
3537
3638public class NetworkChecker extends TimerTask {
@@ -53,6 +55,9 @@ public void start(Timer timer) {
5355
5456 @ Override
5557 public void run () {
58+ if (!hasNetworkInterfaces ()) {
59+ return ;
60+ }
5661 try {
5762 InetAddress [] curentAddresses = topology .getInetAddresses ();
5863 Set <InetAddress > current = new HashSet <>(curentAddresses .length );
@@ -68,4 +73,12 @@ public void run() {
6873 e .printStackTrace ();
6974 }
7075 }
76+
77+ private boolean hasNetworkInterfaces () {
78+ try {
79+ return NetworkInterface .getNetworkInterfaces () != null ;
80+ } catch (SocketException e ) {
81+ return false ;
82+ }
83+ }
7184}
You can’t perform that action at this time.
0 commit comments