Skip to main content
IronRDP provides first-class support for async I/O through the ironrdp-async crate, with runtime-specific implementations for Tokio and Futures. This guide covers async patterns, performance optimization, and best practices.

Async vs Blocking

When to Use Async

✅ Use async I/O when:
  • Handling multiple concurrent connections
  • Building servers that need to scale
  • Integrating with existing async codebases
  • Requiring non-blocking I/O for responsiveness

When to Use Blocking

✅ Use blocking I/O when:
  • Building simple single-connection clients
  • Prototyping or testing
  • Working in environments without async runtime
  • Simplicity is more important than concurrency

Architecture

IronRDP’s async architecture uses these crates:
  • ironrdp-async - Runtime-agnostic async abstractions
  • ironrdp-tokio - Tokio-specific implementations
  • ironrdp-futures - Futures-specific implementations

Async Client Example

Here’s a complete async client using Tokio:

Async Server Example

The ironrdp-server crate is built on async/await:
The server automatically handles multiple clients concurrently.

Concurrency Patterns

Multiple Concurrent Connections

Async Channel Communication

Timeout Handling

Graceful Shutdown

Performance Optimization

Buffering Strategy

Batch Processing

Connection Pooling

Error Handling

Retry Logic

Async Error Propagation

Runtime Selection

Using Tokio

Using async-std (via Futures)

Testing Async Code

Best Practices

  1. Use tokio::spawn for independent tasks - Don’t block the async runtime
  2. Avoid blocking operations - Use async alternatives or spawn_blocking
  3. Handle backpressure - Use bounded channels and flow control
  4. Set timeouts - Always timeout long-running operations
  5. Graceful shutdown - Clean up resources properly
  6. Monitor task health - Use supervision strategies for critical tasks

Next Steps