Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

yuguorui
Copy link

@yuguorui yuguorui commented Jun 2, 2023

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.

Known issue: windows support is broken.

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>
Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw left a 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))
Copy link
Collaborator

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.

@Thomasdezeeuw
Copy link
Collaborator

@yuguorui what do you think about #447? Would that solve your use case (when I add Socket::recvmsg).

@yuguorui
Copy link
Author

yuguorui commented Jun 3, 2023

@yuguorui what do you think about #447? Would that solve your use case (when I add Socket::recvmsg).

Yes, I think it would be a great replacement for this PR. Thank you for your excellent work!

@Thomasdezeeuw
Copy link
Collaborator

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

@yuguorui
Copy link
Author

yuguorui commented Jun 8, 2023

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.

@yuguorui yuguorui closed this Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants