Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class TcpLink
- Object
- ByteLink
- StreamLink
- 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 IOException | Connects. |
Inherited methods
From StreamLink
setStreams, isOpen, write, read, close
Constructor details
TcpLink
public TcpLink(String host, int port)Parameters
hostString- the device’s address
portint- its port
Method details
setConnectTimeout
public void setConnectTimeout(int connectTimeout)How long
open() waits for the connection. Defaults to ten seconds.Parameters
connectTimeoutint- the limit in milliseconds
open
public void open()
throws IOExceptionConnects. Does nothing when already open.
Throws
IOException- when the device cannot be reached