-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Re-addition of std::net::IpAddr
#988
Comments
I missed the discussion around the RFC changes. I apologize if this isn't the usual way to bring up a discussion, but I feel like it's really clunky to have to make my own |
cc me |
@murarth I agree w/ you. I didn't really notice the removal of |
Another point to add, joining / leaving multicast groups should take an IP address as an argument, not a socket address as it does currently. |
I agree with this issue -- I think this was an oversight in considering the usage too narrowly. @alexcrichton, I believe, agrees; I think we can file a PR together with an amendment. |
+1. ran into this last night. it absolutely makes sense to have an enum over addres types irrespective of having a particular to connect to. |
Also revert |
This was re-added some time ago, so closing! |
(Firstly, I saw the discussion around its removal in #923, but that decision appears to have been made before
SocketAddr
was decided to have an enum structure like that ofIpAddr
. I'm thinking maybe it was an oversight thatIpAddr
was left out after that decision. In case it wasn't an oversight, here's my argument in favor of re-introducingIpAddr
.)I propose that the type
IpAddr
, as an enum withV4(Ipv4Addr)
andV6(Ipv6Addr)
variants should be re-added tostd::net
. In my experience, it is often necessary to express an IP address that is either IPv4 or IPv6 without the address being associated with a socket and, therefore, it not having an associated port value. For example, when a server retains the remote addresses of past clients. In such cases, it is not intuitive to store such an address as aSocketAddr
instance. Also, the re-addition would mirror theSocketAddr
enum, which itself hasV4
andV6
variants containing structures to the specific types.Additionally, I propose that the
std::net::LookupHost
type should be reverted to yieldIpAddr
types rather thanSocketAddr
as this also permits dealing with hostnames in cases where they are not directly related to any socket operations. It should be noted that theToSocketAddrs
trait is already widely used withinstd::net
to yield a series ofSocketAddr
instances and keepinglookup_host
as-is would constitute a duplication of this functionality.With these changes, I think it would also be helpful to add a convenience method for creating
SocketAddr
instances; e.g.fn new(ip: &IpAddr, port: u16) -> SocketAddr
.The text was updated successfully, but these errors were encountered: