Merge pull request #830 from BillyNate/fixw10multicast

Multicast fix for Windows 10
This commit is contained in:
Martti Malmi 2019-10-24 12:47:05 +03:00 committed by GitHub
commit 2b82d6211f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,11 @@ Gun.on('create', function(root){
try{ dgram = require("dgram") }catch(e){ return }
var socket = dgram.createSocket({type: "udp4", reuseAddr: true});
socket.bind(udp.port);
socket.bind({port: udp.port, exclusive: true}, function(){
socket.setBroadcast(true);
socket.setMulticastTTL(128);
socket.addMembership(udp.address);
});
socket.on("listening", function(){
try { socket.addMembership(udp.address) }catch(e){ return }