Class TcpLink


public class TcpLink extends StreamLink

A TCP connection to a device on the local network: a receipt printer on port 9100, a ZVT or nexo terminal on its configured port.

Needs Socket.isSupported(): the desktop ports, Android and iOS. A web page cannot open raw sockets.

  • Constructor Details

    • TcpLink

      public TcpLink(String host, int port)
      Parameters
      • host: the device's address

      • port: its port

  • Method Details

    • setConnectTimeout

      public void setConnectTimeout(int connectTimeout)

      How long open() waits for the connection. Defaults to ten seconds.

      Parameters
      • connectTimeout: the limit in milliseconds
    • open

      public void open() throws IOException
      Description copied from class: ByteLink

      Connects. Does nothing when already open.

      Throws
      • IOException: when the device cannot be reached
      Overrides:
      open in class StreamLink
      Throws:
      IOException