UDP Sockets
Introduction
UDP is a connection-less protocol with unreliable delivery.
Using UDP Sockets
Incoming UDP datagrams with maximum size of 30000 bytes are supported (user code can send datagrams up to 65000 bytes). In order to receive UDP datagrams, user needs to register a handler using Handle.Udp
:
port
: local port on which to listen for datagrams.clientAddr
: represents client's IP address.clientPort
: holds client port number.datagram
: incoming UDP datagram.
In order to send a UDP datagram from user code, static method UdpSocket.Send
is used:
ipTo
: destination IP address.portTo
: destination port.portFrom
: local port from which UDP datagram should be sent (usually same port on whichHandle.Udp
was called).datagram
: the actual UDP datagram that should be sent.
In the following example we receive (on port 8787) and send the same echo UDP datagram back to the client:
Last updated