Skip to content

Conversation

john-michaelburke
Copy link
Collaborator

@john-michaelburke john-michaelburke commented Jan 6, 2022

The std::net::UdpSocket we are using implements a nontraditional version of udp with a connection. "Although UDP is a connectionless protocol, this implementation provides an interface to set an address where data should be sent and received from." https://doc.rust-lang.org/std/net/struct.UdpSocket.html

  • This change silences the result of sending a data packet.
    • If not it will throw an error if nothing listens to the udp port.
  • Also sets SO_BROADCAST option.
  • Also changes the bind address to "0.0.0.0:0" to allow the host to automatically select the port as opposed to hardcoding it.

if let Err(err) = client.send(&frame) {
error!("Error sending to device: {}", err);
}
if let Err(_e) = client.send(&frame) {}
Copy link
Collaborator Author

@john-michaelburke john-michaelburke Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there is an accepted way to beat the linter for "not handling" a result. Surprisingly difficult task as it was suggesting options that it would then flag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put a comment within the if that says we're intentionally squelching the error?

@john-michaelburke john-michaelburke changed the title Silence error when sending message over udp socket[CPP-489] Silence error sending msg over udp[CPP-489] Jan 6, 2022
@john-michaelburke john-michaelburke requested a review from a team January 6, 2022 23:11
Copy link
Contributor

@silverjam silverjam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One ask, otherwise looks good

if let Err(err) = client.send(&frame) {
error!("Error sending to device: {}", err);
}
if let Err(_e) = client.send(&frame) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put a comment within the if that says we're intentionally squelching the error?

@john-michaelburke john-michaelburke enabled auto-merge (squash) January 7, 2022 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants