Skip to content

Instantly share code, notes, and snippets.

@captDaylight
Last active October 30, 2020 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save captDaylight/757d921a26b8f30a00b1531ee5bc8c50 to your computer and use it in GitHub Desktop.
Save captDaylight/757d921a26b8f30a00b1531ee5bc8c50 to your computer and use it in GitHub Desktop.
const PORT = 25998;
const HOST = '192.168.1.3';
const dgram = require('dgram');
const server = dgram.createSocket('udp4');
server.on('listening', () => {
const address = server.address();
console.log(`UDP Server listening on ${address.address}:${address.port}`);
});
server.on('message', (message, remote) => {
console.log(`<< ${message} >> `);
if (message.indexOf('[Ent]') > -1) {
console.log(' ');
}
});
server.bind(PORT, HOST);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment