Clients -
socket :
UdpClient
Represents UDP socket client and related remote functions.
Constructor
__init
(Address? localAddress, UdpClientConfig? config)
- localAddress Address? ()
-
Locally binding interface and port
- config UdpClientConfig? ()
-
Configure additional details like read timeout etc.
Remote Methods
Send given data to the specified remote client.
Reads data from the remote client. If the data has the specified length, then wait until that number of bytes are received from the client. Else, return the data available in the OS buffer or wait until data receive. If the request length is lesser than the data in the buffer, then the rest will be discarded.
Closes the client socket connection.
Fields
- localPort int 0
-
the local port number to which this socket is bound
- interface string ()
-
network interface to bind to
- id int 0
-
a unique identifier to identify each client
Send given data to the specified remote client.
Parameters
- content byte
-
the content that wish to send to the client socket
- address Address
-
the address of the remote client socket
-
Return Type
(int | Error) number of bytes got written or an error if encounters an error while writing
Reads data from the remote client. If the data has the specified length, then wait until that number of bytes are received from the client. Else, return the data available in the OS buffer or wait until data receive. If the request length is lesser than the data in the buffer, then the rest will be discarded.
Parameters
- length int - -100
-
Positive integer. Represents the number of bytes which should be read
-
Return Type
([byte, int, Address] | ReadTimedOutError) Content as a byte array, the number of bytes read and the address of the sender or an error if encounters an error while reading