KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Reducing Network Load
PRODUCT: 4D | VERSION: 20 R | PLATFORM: Mac & Win
Published On: August 13, 2025

Broadcasting real-time status updates for example, server status from a server to numerous clients such as fifty or more can place a heavy load on the network if carried out via unicast, as this requires sending an identical packet to each client individually. This approach generates redundant traffic, increases latency, and can cause performance issues on networks with limited bandwidth. While 4D’s UDPSocket class supports UDP communication, developers may by default resort to unicast loops or broadcasts, which either multiply packets unnecessarily (unicast) or inundate the entire network (broadcast). Multicast overcomes these shortcomings by allowing a single packet to be sent to a group address, with network routers efficiently delivering it only to subscribed clients.

To address this, implement multicast using 4D’s UDPSocket class. This enables one packet to be sent which the network then replicates to all subscribers, significantly reducing network load. For instance, from fifty packets down to one when serving fifty clients.

The following 4D code snippet sends a text status to the multicast group 239.0.0.1:12345:

var $socket : 4D.UDPSocket
var $blob : Blob
$socket:=4D.UDPSocket.new()
TEXT TO BLOB("SERVER_OK;uptime=12:34"; $blob; UTF8 text without length)
$socket.send($blob; "239.0.0.1"; 12345)

This image shows a network packet capture interface from wireshark:



Make sure your network routers support IGMP for managing group subscriptions, use a multicast group address within 224.0.0.0–239.255.255.255 (such as 239.0.0.1 for private networks), and open the required UDP port in any host firewalls.