Skip to content

Missing feedback when socket is bound to #11

@garrappachc

Description

@garrappachc

With node.js' dgram socket you can listen to the 'listening' event to ensure the socket is correctly bound to:

import { createSocket } from 'node:dgram'

 const socket = createSocket('udp4')

socket.on('message', (message, rinfo) => {
  //...
})

socket.on('listening', () => {
  console.log(`log receiver listening at ${address.address}:${address.port}`)
})

socket.bind(9871, '0.0.0.0')

It would be nice to have similar functionality in the LogReceiver. Suggested API:

const receiver = new LogReceiver({
  address: "0.0.0.0",
  port: 9871,
});
await receiver.start(); // bind the socket and resolves when the 'listening' event is emitted

or

const receiver = new LogReceiver({
  address: "0.0.0.0",
  port: 9871,
});
await receiver.listening; // resolves when the 'listening' event is emitted or resolves immediately if the socket is already bound

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions