rust-lang / socket2

Advanced configuration options for sockets.

Home Page:https://docs.rs/socket2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for ancillary data receiving

yuguorui opened this issue · comments

There is currently no way to accept ancillary (control) data from the OS.

In the Unix world, it can be achieved through recvmsg, and in the Windows world, it can be achieved through WSARecvMsg.

One of the typical use cases of ancillary (control) data is IP_PKTINFO, which has been implemented by most mainstream OS to distinguish the IP address and NIC receiving the data packet.

[1] Linux: https://man7.org/linux/man-pages/man7/ip.7.html#:~:text=control%20message%20type.-,IP_PKTINFO,-(since%20Linux%202.2
[2] Windows: https://learn.microsoft.com/en-us/windows/win32/winsock/ip-pktinfo?redirectedfrom=MSDN

Related Information: tokio-rs/mio#1679
RFC version of implementation: #446

@yuguorui I think this can be closed now that we support Socket::recvmsg (#447)?

Sure, thanks for your work!