Client: Client

Isolated

Initializes the UDP connectionless client based on the provided configurations.

Constructor

Initializes the UDP connectionless client based on the provided configurations.

1udp:Client|udp:Error? socketClient = new(localHost = "localhost");
init (*ClientConfiguration config)

Remote Methods

sendDatagram

Sends the given data to the specified remote host.

receiveDatagram

Reads data from the remote host.

close

Free up the occupied socket.

sendDatagram

function sendDatagram(Datagram datagram) returns Error?
Isolated Function
Remote Function

Sends the given data to the specified remote host.

1udp:Error? result = socketClient->sendDatagram({remoteHost: "localhost",
2 remotePort: 48826, data:"msg".toBytes()});

Parameters

  • datagram Datagram
  • Contains the data to be sent to the remote host and the address of the remote host

Return Type

(Error?)

() or else a udp:Error if the given data cannot be sent

receiveDatagram

function receiveDatagram() returns (readonly & Datagram) | Error
Isolated Function
Remote Function

Reads data from the remote host.

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

Return Type

((readonly & Datagram) | Error)

A udp:Datagram 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 ()