Crates/Tokio

16 articles
How to create a TCP server Create a Rust TCP server by binding a TcpListener to an address and iterating over incoming streams. How to create a UDP server Create a UDP server in Rust by binding a UdpSocket to an address and looping through recv_from calls to process incoming data. How to gracefully shutdown async tasks in tokio Gracefully shutdown Tokio async tasks by awaiting their JoinHandles or using select! to cancel them on a shutdown signal. How to Profile Async Rust Applications (tokio-console) Install tokio-console and run your app with RUST_LOG enabled to view a live dashboard of async task performance. How to Set Up the Tokio Runtime in Rust Set up the Tokio runtime in Rust by using the trpl::block_on helper to execute async functions. How to use tokio broadcast channel Create a broadcast channel with tokio::sync::broadcast::channel to send messages from one sender to multiple async receivers. How to use tokio crate in Rust async runtime Add the tokio crate with the rt-multi-thread feature and use the #[tokio::main] macro to run async functions. How to use tokio mpsc channel Create an async channel with trpl::channel, send data via tx.send, and receive it with rx.recv.await inside a Tokio runtime. How to use tokio oneshot channel Create a one-time message channel in Rust using tokio::sync::oneshot::channel() to send data between async tasks. How to use tokio select macro The tokio::select! macro runs multiple futures concurrently and executes the code block for whichever one finishes first. How to use tokio spawn Use tokio::task::spawn to run async functions concurrently and get a JoinHandle to await their results. How to Use tokio::spawn for Spawning Async Tasks Use tokio::spawn to run async code in the background and get a handle to retrieve the result later. How to use tokio sync Semaphore Limit concurrent async tasks in Rust by acquiring a permit from a tokio::sync::Semaphore before entering a critical section. How to use tokio watch channel Use tokio::sync::watch::channel to broadcast the latest value to multiple async receivers efficiently. What is the tokio runtime The Tokio runtime is the engine that executes asynchronous Rust code by scheduling tasks and managing resources efficiently. What is tokio task JoinSet A JoinSet manages multiple async tasks and yields results as they complete.