Skip to content

Expose a bind method on UnixStream #6288

@little-dude

Description

@little-dude

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-feature-requestCategory: A feature request.M-netModule: tokio/net

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions