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

Accept ToSocketAddrs #668

Closed
dtolnay opened this Issue Aug 18, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@dtolnay
Copy link

dtolnay commented Aug 18, 2017

The methods that currently accept SocketAddr or &SocketAddr as an argument could take A: ToSocketAddrs, which is implemented for str and various other helpful types.

  • This would match the signatures of std::net's TcpListener, TcpStream, and UdpSocket.
  • It would save a parse().unwrap() in all of our example code.
@alexcrichton

This comment has been minimized.

Copy link
Contributor

alexcrichton commented Aug 18, 2017

Oh this is actually explicitly avoided in mio because of the semantics of ToSocketAddrs. Right now ToSocketAddrs will perform a blocking DNS call (e.g. getaddrinfo) which is something that mio, a crate for nonblocking I/O, in general wants to discourage. In that sense all we really want is T: TryInto<SocketAddr> in the sense that string parsing is fine but we don't want DNS lookups to happen.

That being said, this has come up a few times, so I think it'd at least be worth explicitly documenting!

@dtolnay

This comment has been minimized.

Copy link
Author

dtolnay commented Aug 18, 2017

Okay, makes sense. I agree, let's document this!

@carllerche

This comment has been minimized.

Copy link
Owner

carllerche commented Jan 13, 2019

Closing due to inactivity.

@carllerche carllerche closed this Jan 13, 2019

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.