Represents a netlink listener resource.
Example
const nlListener = listener((msg) => {
print('Received netlink message:', msg, '\n');
}, [RTM_NEWROUTE, RTM_DELROUTE]);
nlListener.set_commands([RTM_GETLINK, RTM_SETLINK]);
nlListener.close();- Source
- See
Methods
close() → {boolean}
Close a netlink listener.
Closes the netlink listener and stops receiving messages.
Returns: boolean
- true if successful, false on error
Example
// Close the listener
listener.close();- Source
set_commands(commands) → {boolean}
Set the commands for a netlink listener.
Updates the set of netlink commands that the listener will receive.
Parameters:
| Name | Type | Description |
|---|---|---|
commands | string[] | Array of netlink commands to listen for |
Returns: boolean
- true if successful, false on error
Example
// Update listener to only receive route messages
listener.set_commands([RTM_NEWROUTE, RTM_DELROUTE]);- Source