close method

Future<void> close()

Closes the connection and fails any calls still waiting.

Implementation

Future<void> close() async {
  if (_closed) return;
  try {
    await _socket.close().timeout(
      const Duration(seconds: 1),
      onTimeout: () {},
    );
  } catch (_) {
    // Closing a broken socket can throw; the connection is gone either way.
  }
  _onDone();
}