freerdp_peer API is the low-level foundation for writing an RDP server in C. The sample server in server/Sample/sfreerdp.c is the canonical reference implementation.
Core lifecycle functions
The listener
Usefreerdp_listener to accept incoming connections. For each accepted connection the library calls your PeerAccepted callback with a ready-to-configure freerdp_peer*.
freerdp_listener function pointers:
Extending rdpContext
Store per-connection application state by embedding rdpContext as the first member of a larger struct:
Key peer callbacks
Set these function pointers on thefreerdp_peer* before calling peer->Initialize(peer).
Connection lifecycle
PostConnect is the right place to open virtual channels and load resources. Return FALSE from any callback to abort the connection.Channel and redirection
Virtual channels (dynamic)
Authentication
peer->settings configuration
Configure settings through peer->context->settings using freerdp_settings_set_* before calling peer->Initialize(peer). Common settings from the sample server:
The peer event loop
Afterpeer->Initialize(peer) succeeds, run a standard Windows-style wait loop:
Input callbacks
Register input handlers onclient->context->input to receive keyboard and mouse events from the client:
Sending graphics updates
Useclient->context->update to push graphics to the client. Always bracket updates with surface frame markers:
Complete minimal server example
The following skeleton combines all the pieces above.The full production-quality example is
server/Sample/sfreerdp.c. It adds RemoteFX/NSCodec rendering, virtual channel management, audio, and PCAP replay support.