Skip to content

Instantly share code, notes, and snippets.

@grizmio
grizmio / client.js
Created July 22, 2022 23:02 — forked from PierBover/client.js
Node.js UDP Broadcast example
const dgram = require('dgram');
const message = new Buffer('Server?');
const socket = dgram.createSocket('udp4');
socket.on('listening', function () {
socket.setBroadcast(true);
setInterval(() => {
socket.send(message, 0, message.length, 5555, '255.255.255.255');
}, 5000);
});