polachok / pnetlink

netlink library for rust
42 stars 13 forks source link

Allow blocking socket to be created #49

Closed arg0d closed 4 years ago

arg0d commented 4 years ago

Allow receiving route events:

let group = MulticastGroup::RTMGRP_LINK | MulticastGroup::RTMGRP_IPV4_IFADDR | MulticastGroup::RTMGRP_IPV6_IFADDR;

let nonblocking = false; let mut socket = NetlinkSocket::bind_with_args(NetlinkProtocol::Route, group.bits(), nonblocking)?;

arg0d commented 4 years ago

Hey guys. Could you take a look at this PR? I would rather merge the changes here, instead of managing my own fork.

Some more context: I want to be notified of routing table change events, using NetLink. https://stackoverflow.com/questions/27008067/how-to-get-notified-about-network-interface-changes-with-netlist-and-rtmgrp-link

Its possible to keep continuously polling the socket, but the code is cleaner if I just block and wait for next message.

@polachok @bkchr