Skip to content

Support abritrary socket adresses #918

@niklaswimmer

Description

@niklaswimmer

Rustix can currently not be used to bind sockets which are not unix or ip. The only real requirement on a socket address is that it starts with an u16 (the address family) - judging from the types used in the definition of the bind syscall.

My specific use case is binding bluetooth sockets and my current workaround is to just call libc::bind instead (using the fd returned by rustix's socket_with).

I am unsure what a good API would look like, but ideally it would not require me to construct a [u8] array myself and instead work with structs which are then automatically converted into byte arrays when it comes to invoking the syscall. For my use case I wrote a helper module that uses unions to convert some struct into a libc::sockaddr if you want to take a look.

This issue also blocks usage of eyra for any programs that need to work with some non-well-known sockets.

I would be happy to help implementing this API, but as noted above I am not sure about the design and would require some input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions