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

SocketAddr argument to UdpSocket methods #667

Open
dtolnay opened this Issue Aug 18, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@dtolnay
Copy link

dtolnay commented Aug 18, 2017

fn bind(addr: &SocketAddr) -> Result<UdpSocket>;
fn connect(&self, addr: SocketAddr) -> Result<()>;

One of these takes a &SocketAddr, the other takes SocketAddr by value. If possible, they should be consistent.

@bobbo

This comment has been minimized.

Copy link

bobbo commented Sep 19, 2017

I'd like to take a look at doing this.

UdpSocket::bind(), UdpSocket::send_to() and TcpStream::connect() take SocketAddr by ref, so that seems the most consistent way to go.

@asayers

This comment has been minimized.

Copy link
Contributor

asayers commented Oct 18, 2017

Or better yet, generalise addr to ToSocketAddrs like the equivalent libstd functions do. This way, it wouldn't even be a breaking change.

EDIT: Well, it's still breaking since it can introduce ambiguity errors.

EDIT: Never mind, I just noticed #668.

carllerche added a commit that referenced this issue Nov 19, 2017

Modify UdpSocket::connect() to take SocketAddr by ref (#667) (#731)
Modify UdpSocket::connect() to take SocketAddr by ref, to be consistent
with other UdpSocket / TcpStream methods. The std equivalent takes
`T: ToSocketAddrs`, which we cannot do with mio as that implies
blocking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.