You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should socket2 support sendmsg/recvmsg including control ancillary data to expose things like IP_TTL and IPV6_PKTINFO.
I took a quick stab at it to figure out how it'd look like. I only did the writing side, I think there's a lot of design work and discussion here and I'm more than half-convinced this should be an enum instead of what I wrote.
I think it'd be interesting to basically provide some safe wrappers around CMSG and the many control data types. Unclear if it's in the interest of the authors of the crate to maintain all of those, however. Also I have 0 experience with Windows here so I didn't even try satisfying it with my prototype, and I'm honestly not even sure where to begin there.
Interested to hear the maintainer's thoughts. I'm willing to iterate on design and implementation here if there is interest.
Note: This is somewhat related to #86 from what I gathered in the discussion over there.
@brunowonka I don't really have time to review this at the moment, but if you open a draft pr I can start reviewing the code once I have some time. In general I think that if the API surface isn't too big socket2 should be able to support this.
As an argument for supporting sendmsg/recvmsg, if you want to modify the interface or ip used when sending or receiving a message while bound to ipaddr_any, for instance, those methods are necessary. dnsmasq does this in its DHCP impl. If socket2 is meant to support "advanced configuration options" it seems like something it should be able to do.
edit: it looks like quinn uses sendmmsg/recvmmsg on linux but falls back to just send_to/recv_from on windows? see here
Reading and writing PKTINFO would also be of great help for std_embedded_nal, as having the local address is mandatory for that interface, to allow QUIC and CoAP implementations. (Right now, that crate goes through nix, but this crate could offer it in a sufficiently abstract way that even Windows can be supported).
Activity
Thomasdezeeuw commentedon Jun 19, 2022
@brunowonka I don't really have time to review this at the moment, but if you open a draft pr I can start reviewing the code once I have some time. In general I think that if the API surface isn't too big socket2 should be able to support this.
Initial basic cmsg support for unix
brunowonka commentedon Jun 23, 2022
Thanks @Thomasdezeeuw, opened #316 to get the conversation started
leshow commentedon Jun 30, 2022
I don't have an opinion on the code per-say, but I did want to link some other resources I stumbled across that may be helpful:
cmsgtype that may be informativeAs an argument for supporting
sendmsg/recvmsg, if you want to modify the interface or ip used when sending or receiving a message while bound to ipaddr_any, for instance, those methods are necessary.dnsmasqdoes this in its DHCP impl. Ifsocket2is meant to support "advanced configuration options" it seems like something it should be able to do.edit: it looks like
quinnusessendmmsg/recvmmsgon linux but falls back to justsend_to/recv_fromon windows? see hereInitial basic cmsg support for unix
the8472 commentedon Mar 28, 2023
There also is some incomplete work in the standard library
leshow commentedon Mar 29, 2023
If this is useful for anyone, I extracted some of the code from
quinninto a library that hassendmsg/recvmsgfor tokio & std https://github.com/leshow/unix-udp-sockchrysn commentedon Nov 29, 2023
Reading and writing PKTINFO would also be of great help for std_embedded_nal, as having the local address is mandatory for that interface, to allow QUIC and CoAP implementations. (Right now, that crate goes through nix, but this crate could offer it in a sufficiently abstract way that even Windows can be supported).
Thomasdezeeuw commentedon Jan 25, 2025
We now support this with
MsgHdrMutandMsgHdr,recvmsgandsendmsg.