-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add equivalents for INADDR_ANY, INADDR_LOOPBACK to std::net #39819
Comments
Currently in Rust you either write these out as strings (which all the examples in |
cc @rust-lang/libs, I assume we probably want this developed out-of-tree as per usual? Probably in the |
These are just a couple of new consts, right? I don't see any reason to not just add them (unstable at first of course). |
I believe so, though I'm uncertain. @luser Are these just a set of constants? |
Yes, these are all just constants. |
I believe we are ready to consider a PR exposing these constants. |
This was fixed in #44582 https://github.com/rust-lang/rust/blob/master/RELEASES.md#stabilized-apis Hooray! |
POSIX defines:
INADDR_ANY
, which is 0.0.0.0 as anin_addr
INADDR_BROADCAST
, which is 255.255.255.255 as anin_addr
in6addr_any
+IN6ADDR_ANY_INIT
, which is the same concept as anin6_addr
(with wonky variable + macro usage because structs in C are terrible)in6addr_loopback
+IN6ADDR_LOOPBACK_INIT
, which is::1
as anin6_addr
glibc additionally defines:
INADDR_LOOPBACK
, which is 127.0.0.1 (I don't know why this isn't in POSIX)INADDR_NONE
, which is just used as an error return, so not really useful in RustI think it would be useful to have at least consts for the
ANY
+LOOPBACK
values for IPv4 and IPv6 instd::net
.From cursory googling while looking up the sources above I did find a few people wondering why these were missing from the Rust standard library:
https://users.rust-lang.org/t/where-is-inaddr-any-for-std-net/2337
https://www.reddit.com/r/rust/comments/3gi34h/inaddr_any_in_rust/
The text was updated successfully, but these errors were encountered: