connect static method

Implementation

static Future<Comm> connect(ConnectionSettings c) async {
  assert(!c.useCompression!);

  Comm? comm;
  final handshakeCompleter = Completer();

  final socket = await BufferedSocket.connect(c.host, c.port,
      onDataReady: () => comm?.readPacket(),
      onError: (error) {
        // If conn has not been connected there was a connection error.
        if (comm == null) {
          handshakeCompleter.completeError(error);
        } else {
          comm.forwardError(error);
        }
      },
      onClosed: () {
        comm!.forwardError(SocketException.closed());
      });

  var handler =
      HandshakeHandler(c.user, c.password, c.maxPacketSize, c.characterSet, c.db, c.useCompression, c.useSSL);

  comm = Comm(socket, handler, handshakeCompleter, c.maxPacketSize);

  await handshakeCompleter.future;

  return comm;
}