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

Expose a bind method on UnixStream #6288

Closed
little-dude opened this issue Jan 16, 2024 · 2 comments · Fixed by #6290
Closed

Expose a bind method on UnixStream #6288

little-dude opened this issue Jan 16, 2024 · 2 comments · Fixed by #6290
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-net Module: tokio/net

Comments

@little-dude
Copy link

Is your feature request related to a problem? Please describe.

Although very unconventional, it may be useful to bind a unix socket to a specific path. In my case, the listener calls UnixStream::peer_addr() upon accepting an incoming connection, and the path contains information necessary to process the connection.

Describe the solution you'd like

Allow users to create a UnixStream bound to a specific path. socket2 exposes a bind for this. I'm not sure how to make this fully backward compatible in tokio case though, since UnixStream::connect is currently the only way to create a socket.

Describe alternatives you've considered

  • creating a socket2 socket, using AsyncFd for the connection, then convert the socket into a tokio socket
  • creating a socket2 socket, make a blocking connect call, then convert the socket into a tokio socket
@little-dude little-dude added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Jan 16, 2024
@Darksonn Darksonn added the M-net Module: tokio/net label Jan 16, 2024
@Darksonn
Copy link
Contributor

This is unlikely to be exposed as a bind call on UnixStream. Rather, it makes more sense to provide a UnixSocket type analogous to TcpSocket.

@evanrittenhouse
Copy link
Contributor

I'm interested in this, but don't have a ton of experience working with Unix sockets - I wonder if it makes sense to create a Socket trait and pull some of the methods out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-net Module: tokio/net
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants