-
Notifications
You must be signed in to change notification settings - Fork 168
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
Support abritrary socket adresses #918
Comments
Interesting question. I think my preference here is to add a That said, at a quick search, I found about 40 However, my guess is, for now, it makes sense to stick with typed interfaces and adding address families such as Does that make sense? |
I tried to add |
The purpose of having |
For clarification, I am talking about the syscall side. |
Would it make sense to have a trait SocketAddr {
fn encode(&self) -> SocketAddrStorage;
fn decode(storage: &SocketAddrStorage) -> Result<Self>;
} I am not sure why we currently have two methods of encoding/decoding, and duplicate for both backends for each sockaddr (4 redundant copies!). |
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'ssocket_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.
The text was updated successfully, but these errors were encountered: