UDP – User Datagram Protocol, is a transport layer protocol. This is the same layer as TCP.
Unlike TCP, UDP is connection-less (stateless) and not 100% reliable.
The fact that a connection is not required makes it very simple to use UDP. You just open a UDP socket and send data. No need to maintain an active connection like with TCP.
UDP is suitable in cases where loss of data is not critical. For example audio or video streaming.
Applications can add checksums to verify the data, however packets can be lost and in some edge cases, can be duplicated.
If you find yourself trying to make UDP fully reliable then it is a good sign that you should switch to TCP.
UDP is also a good choice for interprocess-communication as it is unlikely that packets will be lost.
UDP communication is done in B4X using UDPSocket and UDPPacket from the network libraries. Note that AsyncStreams is not used with UDP as the communication is not stream-based. You can use B4XBytesBuilder from B4XCollections to collect packets if needed.
UDP packets can be broadcasted in local networks. This is useful to implement auto discovery features. For example, the IDE broadcasts a message on a specific port and B4A-Bridge / B4i-Bridge clients reply with their addresses and devices names.
Auto discovery example: https://www.b4x.com/android/forum/threads/mqtt-chat-with-auto-discovery.75713/#content