checkIdeConnection method

Future<bool> checkIdeConnection(
  1. String host,
  2. int port, {
  3. Duration timeout = const Duration(milliseconds: 500),
})

Check if an IDE connection is responding by testing if the port is open.

Implementation

Future<bool> checkIdeConnection(
  String host,
  int port, {
  Duration timeout = const Duration(milliseconds: 500),
}) async {
  try {
    final socket = await Socket.connect(host, port, timeout: timeout);
    socket.destroy();
    return true;
  } catch (_) {
    return false;
  }
}