The promisified-udp-client
is an NPM package that provides a simple way to create UDP clients with a promise-based interface. This allows for easy interaction using await, streamlining the process of sending and receiving UDP messages.
To install the package, use the following command in your project:
npm install promisified-udp-client
const client = new UdpClient();
await client.connect(8080, `127.0.0.1`);
await client.send(`Test message`);
client.close();
client.addErrorListener((msg: Buffer, rinfo: dgram.RemoteInfo) => console.log(msg, rinfo));
client.removeErrorListener(errorListenerMethod);
client.addMessageListener((msg: Buffer, rinfo: dgram.RemoteInfo) => console.log(msg, rinfo));
client.removeMessageListener(messageListenerMethod);
await client.connect(port, address);
await client.send(msg: string | readonly any[] | Uint8Array);
await client.close();
client.socket