-
Notifications
You must be signed in to change notification settings - Fork 227
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
[RFC] Add support for receiving ancillary data #446
Conversation
Two new methods are added in order to receive ancillary data along with normal data. The methods are `recv_with_ancillary_data` and `recv_vectored_with_ancillary_data_and_flags`. The former is easier to use, while the latter provides the flexibility. The implementation includes changes to the `recvmsg` function in the `sys/unix.rs` file to handle the ancillary data. A new test case is also added to test the `recv_with_ancillary_data` method. Signed-off-by: yuguorui <yuguorui@pku.edu.cn>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should find a nice way to expose recvmsg
(and sendmsg
) instead of adding more methods that wrap it?
We'll need a nice wrapper around the msghdr
/WSAMSG
types. I might have some time to look into this this weekend.
@@ -950,7 +950,18 @@ pub(crate) fn recv_vectored( | |||
bufs: &mut [crate::MaybeUninitSlice<'_>], | |||
flags: c_int, | |||
) -> io::Result<(usize, RecvFlags)> { | |||
recvmsg(fd, ptr::null_mut(), bufs, flags).map(|(n, _, recv_flags)| (n, recv_flags)) | |||
recvmsg(fd, ptr::null_mut(), bufs, &mut [], flags).map(|(n, _, recv_flags)| (n, recv_flags)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the addition of &mut []
will be invalid as the pointer will be non-null.
Ok, no problem. I've been trying to find some workrounds for recvmsg on Windows, but unfortunately haven't found any continuous free time this week. Thanks again for your quick response. |
Two new methods are added in order to receive ancillary data along with normal data. The methods are
recv_with_ancillary_data
andrecv_vectored_with_ancillary_data_and_flags
. The former is easier to use, while the latter provides the flexibility.The implementation includes changes to the
recvmsg
function in thesys/unix.rs
file to handle the ancillary data.A new test case is also added to test the
recv_with_ancillary_data
method.Known issue: windows support is broken.