1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-24 13:52:14 +01:00

29 lines
618 B
Java
Raw Normal View History

package processing.app.helpers;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
public abstract class NetUtils {
public static boolean isReachable(InetAddress address, int port) {
Socket socket = null;
try {
socket = new Socket();
socket.connect(new InetSocketAddress(address, port), 300);
return true;
} catch (IOException e) {
return false;
} finally {
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
// noop
}
}
}
}
}