Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const dgram = require('dgram');
- const broadcastServer = dgram.createSocket('udp4');
- broadcastServer.on('message', (msg, rinfo) => {
- console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
- broadcastServer.send(hostAddr, 0 , hostAddr.length, 35124, rinfo.address);
- console.log(`server broadcast ${hostAddr} to ${rinfo.address}`);
- });
- broadcastServer.bind(broadcastPort, function(){
- broadcastServer.setBroadcast(true);
- });
Advertisement
Add Comment
Please, Sign In to add comment