Client: Client

Initializes the TCP connection client based on the provided configurations.

Constructor

Initializes the TCP client based on the provided configurations.

1tcp:Client|tcp:Error? socketClient = new("www.remote.com", 80,
2 localHost = "localHost");
init (string remoteHost, int remotePort, *ClientConfiguration config)
  • remoteHost string
  • The hostname or the IP address of the remote host

  • remotePort int
  • The port number of the remmote host

Remote Methods

writeBytes

Sends the given data to the connected remote host.

readBytes

Reads data only from the connected remote host.

close

Free up the occupied socket.

writeBytes

function writeBytes(byte[ ] data) returns Error?
Remote Function

Sends the given data to the connected remote host.

1tcp:Error? result = socketClient->writeBytes("msg".toBytes());

Parameters

  • data byte[ ]
  • The data need to be sent to the connected remote host

Return Type

(Error?)

() or else a tcp:Error if the given data can't be sent

readBytes

function readBytes() returns (readonly & byte[ ]) | Error
Remote Function

Reads data only from the connected remote host.

1(readonly & byte[])|tcp:Error result = socketClient->readBytes();

Return Type

((readonly & byte[ ]) | Error)

The readonly & byte[], or else a tcp:Error if the data can't be read from the remote host

close

function close() returns Error?
Isolated Function
Remote Function

Free up the occupied socket.

1tcp:Error? closeResult = socketClient->close();

Return Type

(Error?)

A tcp:Error if it can't close the connection or else ()