Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class TcpLink

  1. Object
  2. ByteLink
  3. StreamLink
  4. TcpLink

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.

Constructors

public TcpLink(String host, int port)

Methods

public void setConnectTimeout(int connectTimeout)How long open() waits for the connection.
public void open() throws IOExceptionConnects.

Inherited methods

Constructor details

TcpLink

public TcpLink(String host, int port)

Parameters

host String
the device’s address
port int
its port

Method details

setConnectTimeout

public void setConnectTimeout(int connectTimeout)
How long open() waits for the connection. Defaults to ten seconds.

Parameters

connectTimeout int
the limit in milliseconds

open

public void open() throws IOException
Connects. Does nothing when already open.

Throws

IOException
when the device cannot be reached