| Crates.io | tokio-quicker |
| lib.rs | tokio-quicker |
| version | 0.0.2 |
| created_at | 2024-01-28 23:22:29.826749+00 |
| updated_at | 2024-01-28 23:34:55.951956+00 |
| description | A easy-to-use quic library for tokio. |
| homepage | https://github.com/cauvmou/tokio-quicker |
| repository | |
| max_upload_size | |
| id | 1117983 |
| size | 84,269 |
Async QUIC Listener/Socket for tokio using quiche.
First create a QuicSocket.
let mut connection = QuicSocket::bind("127.0.0.1:0")
.await?
.connect(Some("localhost"), "127.0.0.1:4433")
.await?;
Then you can start opening new QuicStreams or receive incoming ones from the server.
let mut stream = connection.bidi(1).await?;
let mut stream = connection.incoming().await?;
These implement the tokio AsyncRead and AsyncWrite traits.
Again create a QuicListener.
let mut listener = QuicListener::bind("127.0.0.1:4433").await?;
Then you can use a while loop to accept incoming connection and either handle them directly on the thread or move them to a new one.
while let Ok(mut connection) = listener.accept().await {
tokio::spawn(async move {
let mut stream = connection.incoming().await?;
...
stream.shutdown().await?;
});
}