Is there a simple socket that implements AsyncWrite and AsyncRead?

async_std - Rust is massive, has multiple dependencies and my project already has too many of them.

I just want a simple socket with that implements AsyncWrite and AsyncRead. Is there such socket for Rust?

I believe async-net is pretty much just the code from the net module of async-std with whatever else is needed to make it functional as a standalone package. I’ve never tried it though.

The issue with what you're asking for is that generally you will need a runtime to handle the async scheduling. async-std and Tokio are two frameworks that have all the network code as well as a runtime.

Now if you really don't want those things, you'll probably want to check out mio which does place sockets into non-blocking mode, and offer cross-platform async IO support. This does not implement AsyncRead or AsyncWrite, though. AsyncRead and AsyncWrite have custom implementations in both async-std and Tokio, because they tend to be written with their specific runtimes in mind.

Anyway, the point is, if you opt to not use these or any other runtime, your going to run into areas where you'll need to do a significant amount of work to replicate what they do.

I believe in this case though, you could also just use async-executor with async-net. Though I’m not sure how much lighter that is than just using async-std

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.