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
Open

Add AsyncFd::try_io #4719

jyn514 opened this issue May 27, 2022 · 5 comments
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.

@Pyrromanis
Copy link
Contributor

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
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

No branches or pull requests

4 participants