The screenshot example demonstrates how to build a basic RDP client using IronRDP in a blocking, synchronous manner. It connects to an RDP server, receives graphics updates, and saves the resulting image to disk.
Overview
Location: crates/ironrdp/examples/screenshot.rs
Purpose: Demonstrate basic RDP client implementation with minimal code
Key Features:
- Blocking I/O using
ironrdp-blocking
- TLS upgrade with custom certificate verification
- Graphics decoding and image processing
- Configurable compression settings
- PNG image output
Usage
Basic Usage
With Compression
With Logging
Command-Line Arguments
Code Walkthrough
1. Argument Parsing
See: screenshot.rs:123
2. Configuration
See: screenshot.rs:209
3. Connection Establishment
See: screenshot.rs:290
4. TLS Upgrade
See: screenshot.rs:381
5. Active Stage Processing
See: screenshot.rs:342
6. Image Output
See: screenshot.rs:180
Compression Levels
Compression levels map to RDP compression types:
See: screenshot.rs:278
Certificate Verification
The example uses a custom certificate verifier for testing purposes:
This certificate verifier accepts ALL certificates without validation. Only use this for testing! Production code should implement proper certificate validation.
See: screenshot.rs:441
Key Takeaways
- Blocking I/O: Uses standard library
TcpStream and ironrdp-blocking for simple synchronous operation
- State Machine: Connection follows a clear state machine pattern (begin → upgrade → finalize)
- Graphics Processing: Uses
DecodedImage to accumulate graphics updates
- Error Handling: Leverages
anyhow for convenient error propagation
- Timeout Handling: Uses
WouldBlock error to exit the processing loop cleanly
Further Reading