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

Use std::os::unix::net::SocketAddr instead of mio::net::SocketAddr #1527

Open
Thomasdezeeuw opened this issue Nov 7, 2021 · 6 comments · May be fixed by #1749
Open

Use std::os::unix::net::SocketAddr instead of mio::net::SocketAddr #1527

Thomasdezeeuw opened this issue Nov 7, 2021 · 6 comments · May be fixed by #1749
Milestone

Comments

@Thomasdezeeuw
Copy link
Collaborator

It's the same type. It's only implemented by us because we can't create std::os::unix::net::SocketAddr.

@Thomasdezeeuw Thomasdezeeuw added this to the v1.0 milestone Nov 7, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 28, 2022
…r=m-ou-se

Add os::unix::net::SocketAddr::from_path

Creates a new SocketAddr from a path, supports both regular paths and
abstract namespaces.

Note that `SocketAddr::from_abstract_namespace` could be removed after this as `SocketAddr::unix` also supports abstract namespaces.

Updates rust-lang#65275
Unblocks tokio-rs/mio#1527

r? `@m-ou-se`
@Thomasdezeeuw
Copy link
Collaborator Author

We can do this in 1.61.

@Noah-Kennedy
Copy link

@Thomasdezeeuw is it confirmed to be stabilizing then?

@Thomasdezeeuw
Copy link
Collaborator Author

@Noah-Kennedy it's stabilised in rust-lang/rust#94356.

@RealXuChe
Copy link

From #1605, I want to notice you that there may be a regression in the replacement: As you can see here, std::os::unix::net::SocketAddr doesn't support binding to a path with \0 in it, which means it doesn't support abstract Unix socket.

Of course, there's no reason for std::os::unix::net::SocketAddr to support abstract Unix socket, since abstract Unix socket is a Linux feature, and not in the Unix spec.

But mio has already supported abstract Unix socket, though it's a little buggy, like there's no conditional compilation to make it only work on Linux.

So this replacement will possibly break the use of abstract Unix socket, I think we need to be careful on this.

(Sorry for my bad English)

@Thomasdezeeuw
Copy link
Collaborator Author

I think the support is still unstable, but it's should come at some point: https://doc.rust-lang.org/std/os/unix/net/struct.SocketAddr.html#method.from_abstract_namespace. Maybe we can create a pr to stabilise it.

@gustav3d
Copy link

gustav3d commented Aug 31, 2022 via email

Thomasdezeeuw added a commit that referenced this issue Dec 24, 2023
Replaces mio::net::SocketAddr with std::os::unix::net::SocketAddr.

With this change the path based API to create the sockets
({UnixDatagram,UnixListener}::bind and UnixStream::connect) will no
longer work with abstract namespaces. For that the _addr variant must be
used and the address created by using SocketAddr::from_abstract_name
(part of the std::os::linux::net::SocketAddrExt trait).

Adds UnixDatagram::bind_addr to match UnixStream::connect_addr and
UnixListener::bind_addr.

Expands the unix_listener_abstract_namespace test to run on Android and
actually create a listener and use it.

Closes #1527
@Thomasdezeeuw Thomasdezeeuw linked a pull request Dec 24, 2023 that will close this issue
Thomasdezeeuw added a commit that referenced this issue Dec 24, 2023
Replaces mio::net::SocketAddr with std::os::unix::net::SocketAddr.

With this change the path based API to create the sockets
({UnixDatagram,UnixListener}::bind and UnixStream::connect) will no
longer work with abstract namespaces. For that the _addr variant must be
used and the address created by using SocketAddr::from_abstract_name
(part of the std::os::linux::net::SocketAddrExt trait).

Adds UnixDatagram::bind_addr to match UnixStream::connect_addr and
UnixListener::bind_addr.

Expands the unix_listener_abstract_namespace test to actually create a
listener and use it.

Closes #1527
Thomasdezeeuw added a commit that referenced this issue Dec 24, 2023
Replaces mio::net::SocketAddr with std::os::unix::net::SocketAddr.

With this change the path based API to create the sockets
({UnixDatagram,UnixListener}::bind and UnixStream::connect) will no
longer work with abstract namespaces. For that the _addr variant must be
used and the address created by using SocketAddr::from_abstract_name
(part of the std::os::linux::net::SocketAddrExt trait).

Adds UnixDatagram::bind_addr to match UnixStream::connect_addr and
UnixListener::bind_addr.

Expands the unix_listener_abstract_namespace test to actually create a
listener and use it.

Closes #1527
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants