connect method

Future<PosPrintResult> connect(
  1. String host, {
  2. int port = 91000,
  3. Duration timeout = const Duration(seconds: 5),
})

Implementation

Future<PosPrintResult> connect(String host,
    {int port = 91000, Duration timeout = const Duration(seconds: 5)}) async {
  _host = host;
  _port = port;
  try {
    _socket = await Socket.connect(host, port, timeout: timeout);
    _socket.add(_generator.reset());
    return Future<PosPrintResult>.value(PosPrintResult.success);
  } catch (e) {
    return Future<PosPrintResult>.value(PosPrintResult.timeout);
  }
}