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

Add AsyncFd::try_io #4719

Open
jyn514 opened this issue May 27, 2022 · 5 comments · May be fixed by #6967
Open

Add AsyncFd::try_io #4719

jyn514 opened this issue May 27, 2022 · 5 comments · May be fixed by #6967
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-io Module: tokio/io

Comments

@jyn514
Copy link
Contributor

jyn514 commented May 27, 2022

Is your feature request related to a problem? Please describe.

I have a Unix socket where I want to call libc::sendmsg on the file descriptor directly. Right now, I have to use

let guard = async_fd.writable().await;
sendmsg(...);
guard.clear_ready();

which is error prone.

Describe the solution you'd like

It would be convenient to allow using try_io instead, like for UdpSocket:

async_fd.try_io(Interest::WRITABLE, || sendmsg(...));

Describe alternatives you've considered
Keep using writable() guard.
Implement sendmsg APIs in tokio directly (#2975).

Additional context
https://discord.com/channels/500028886025895936/500336333500448798/979801318375964733

@jyn514 jyn514 added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels May 27, 2022
@Noah-Kennedy
Copy link
Contributor

This seems like a good idea.

@gpyrros
Copy link
Contributor

gpyrros commented Jun 16, 2022

I'd like to give this a try

@Noah-Kennedy
Copy link
Contributor

@jyn514 we have unix socket types, why not use those for your use case?

@jyn514
Copy link
Contributor Author

jyn514 commented Jun 16, 2022

@Noah-Kennedy I have a trait that abstracts over different socket types.

@Noah-Kennedy
Copy link
Contributor

Ah ok

@Darksonn Darksonn added the M-io Module: tokio/io label Jan 16, 2023
@de-vri-es de-vri-es linked a pull request Nov 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-io Module: tokio/io
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants