connect method

Future<void> connect(
  1. dynamic host,
  2. int port, [
  3. Duration? timeout
])

Implementation

Future<void> connect(dynamic host, int port, [Duration? timeout]) async {
  _socket = await Socket.connect(host, port, timeout: timeout);
  _subscription = _socket
      ?.asyncExpand((bytes) => Stream.fromIterable(bytes))
      .listen(
        (_) {},
        onError: (_) async => await disconnect(),
        onDone: () async => await disconnect(),
      );
  _subscription?.pause();
}