Client: ConnectClient

Isolated

Initializes the UDP connection oriented client based on the provided configurations.

Constructor

Initializes the UDP connect client based on the provided configurations.

1udp:ConnectClient|udp:Error? socketClient = new("www.remote.com", 80,
2 localHost = "localHost");
init (string remoteHost, int remotePort, *ConnectClientConfiguration 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?
Isolated Function
Remote Function

Sends the given data to the connected remote host.

1udp: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 udp:Error if the given data can't be sent

readBytes

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

Reads data only from the connected remote host.

1udp:Datagram|udp:Error result = socketClient->receiveDatagram();

Return Type

((readonly & byte[ ]) | Error)

A byte[] or else a udp:Error if the data cannot be read from the remote host

close

function close() returns Error?
Isolated Function
Remote Function

Free up the occupied socket.

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

Return Type

(Error?)

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