Skip to content

Commit

Permalink
Simplify using recv_from_full
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero committed Oct 27, 2024
1 parent 2b2b4ab commit 8c6402e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions examples/listen_uevents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ use kobject_uevent::UEvent;
fn main() {
let mut socket = Socket::new(NETLINK_KOBJECT_UEVENT).unwrap();
let sa = SocketAddr::new(process::id(), 1);
let mut buf = vec![0u8; 1024 * 8];

socket.bind(&sa).unwrap();

loop {
let n = socket.recv(&mut buf, 0).unwrap();
while let Ok((buf, _addr)) = socket.recv_from_full() {
let s = std::str::from_utf8(&buf).unwrap();
let u = UEvent::from_netlink_packet(&buf).unwrap();
println!(">> {}", s);
Expand Down

0 comments on commit 8c6402e

Please sign in to comment.