TcpListener::bind_to_port and related changes#23161
Conversation
IPV6_V6ONLY is false by default on Linux and OSX (checked myself), and true by default on Windows [1]. Windows set this option to true for backward compatibility, but rust has no that requirement, and it is important for rust have TcpListener code work same way on all platforms. Didn't try code on Windows, however, I tried it on OSX with `cfg!(windows)` commented out. [1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms738574%28v=vs.85%29.aspx
`bind_to_port(port)` is just a shortcut to `bind(&("::", port))`.
However, it is important to have this function to emphasize that
returned socket listens on both IPv4 and IPv6.
|
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
|
Thanks for the PR! Changes like this, however, should go through the RFC process instead of being made through a PR first. We do plan on allowing advanced configuration of sockets other than the high level convenience constructors of |
|
@alexcrichton could you please explain what exactly should I do? Create an issue in rust-lang/rfcs/? Write a new RFC or patch existing RFC 517? Shouldn't I submit a new PR with first two patches of this PR? I. e. patches that just unify |
|
To add these now an RFC would be written, but I would recommend creating a " I don't think that we want the second patch for now, however. We've been recently moving a bit away from that sort of compatibility across OSes. For example the code to explicitly prevent opening a directory was removed along with special Windows-specific code to remove readonly files. We've been moving more in a direction that the implementation of the underlying primitive is clear and easy to understand without having any form of "magic" happening under the hood (e.g. setting some options only on some platforms). I do understand that this make is such that the precise behavior is not cross platform, but that is somewhat of an inevitability. |
|
I've created a long list of issues. |
|
Thanks! |
IPV6_V6ONLYsetsockopt constantbind_to_portshortcut to hide all those details from rust usersNote, I didn't try code on Windows. Only tried on OSX with
if cfg!(windows)line commented out, in which casesetsockoptis called and did nothing, but at least, it didn't fail, and tests passed.