0

i need a udp client wait for udp server to be created to connect and send first message.

const dgram = require('dgram');    
const client = dgram.createSocket('udp4');
client.connect(27015, 'localhost', function()  {

client.send(message, (err) => {

});

});

this code works when the udp server is already running, but do nothing if I first start the client and then server. I need it to work in both cases.

1 Answers1

1

UDP is a connection-less and an unreliable protocol, there is no way to know if the server is running or not on the client side.

See Difference between TCP and UDP?

ozanbora
  • 108
  • 2
  • 6