Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change UdpMetricSink to use UdpSocket::connect method? #17

Closed
56quarters opened this issue Jul 17, 2016 · 1 comment
Closed

Change UdpMetricSink to use UdpSocket::connect method? #17

56quarters opened this issue Jul 17, 2016 · 1 comment
Assignees
Milestone

Comments

@56quarters
Copy link
Owner

Potentially have the sink call UdpSocket::connect to set the address that will be written too.

Pros:

  • We aren't doing the address parsing ourself
  • Our code becomes cleaner
  • Remove address from the struct

Cons:

@56quarters 56quarters added this to the 0.6.0 milestone Jul 17, 2016
@56quarters 56quarters self-assigned this Jul 17, 2016
@56quarters
Copy link
Owner Author

This isn't going to be implemented since it ends up changing behavior when writing to non-existent servers.

Example using UdpSocket::send_to that doesn't result in any write errors:

https://play.rust-lang.org/?gist=3c41ee4e64d5174a46f96c03fb2a8bd5&version=nightly&backtrace=0

use std::net::UdpSocket;

fn main() {
    let socket = UdpSocket::bind("0.0.0.0:0").unwrap();
    socket.send_to("foo:5|c".as_bytes(), "127.0.0.1:8125").unwrap();
    println!("{:?}", socket.take_error());
}

Example using UdpSocket::connect and UdpSocket::send that results in an error:

https://play.rust-lang.org/?gist=7abe83a3abba7fc7c167395128cdd3d3&version=nightly&backtrace=0

use std::net::UdpSocket;

fn main() {
    let socket = UdpSocket::bind("0.0.0.0:0").unwrap();
    socket.connect("127.0.0.1:8125").unwrap();
    socket.send("foo:5|c".as_bytes()).unwrap();
    println!("{:?}", socket.take_error());
}

I don't know what to make of this. However, it will definitely result in a behavior change for the client for no good reason that I don't fully understand. It also seems counter to the idea of UDP: If I'm sending a UDP datagram I shouldn't care if the other side is up, down, or on fire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant