ballerina/udp Ballerina library
This module provides APIs for sending/receiving datagrams to/from another application process (local or remote) using UDP.
When the local host address or the IP address is not given to the optional
localHost field, the
localhost address is bound by default.
The port number of the local port, which is used to connect to the remote server is determined randomly (ephemeral port).
udp:Client is used to interact with the remote UDP host and it can be defined as follows:
udp:ConnectClient is configured by providing the
remotePort so that it only receives data from and sends data to the configured remote host. Once connected, data may not be received from or sent to any other hosts. The client remains connected until it is explicitly closed.
If the number of bytes given to the
writeBytes method is greater than the data size allowed by a datagram, it will iteratively send all the bytes with several datagrams.
udp:Listener is used to listen to the incoming socket request.
udp:Listener can have the following methods.
onBytes(readonly & byte data, udp:Caller caller) or
onDatagram(readonly & udp:Datagram, udp:Caller): These remote methods get invoked once the content is received from the client. The client is represented using the
onError(readonly & udp:Error err): This remote method is invoked in an error situation.
udp:Listenercan be defined as follows:
Released date: about 2 months ago
Ballerina version: 2201.8.0
GraalVM compatible: Yes
Pull count: 275