Skip to content

Commit

Permalink
try bind instead of connect to make linux work
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlee337 committed Feb 7, 2025
1 parent 36cf306 commit 9e67ac4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ export function startBroadcasting() {
broadcastSocket.on('error', (e) => {
reject(e);
});
broadcastSocket.on('connect', () => {
broadcastSocket.on('listening', () => {
if (!broadcastSocket) {
reject();
return;
Expand All @@ -880,16 +880,21 @@ export function startBroadcasting() {
const selfName = getComputerName();
const broadcast = () => {
if (broadcastSocket) {
broadcastSocket.send(selfName);
broadcastSocket.send(selfName, PORT, '255.255.255.255');
timeout = setTimeout(() => {
broadcast();
}, 1000);
}
};
broadcast();
resolve(broadcastSocket.address().address);
const checkSocket = createSocket('udp4');
checkSocket.connect(53, '8.8.8.8', () => {
const resolveAddress = checkSocket.address().address;
checkSocket.close();
resolve(resolveAddress);
});
});
broadcastSocket.connect(PORT, '255.255.255.255');
broadcastSocket.bind();
});
}

Expand Down

0 comments on commit 9e67ac4

Please sign in to comment.