freerdp_peer instance that drives the RDP protocol state machine for that client.
Header: <freerdp/peer.h>
Lifecycle
freerdp_peer_new
NULL on allocation failure. The returned pointer must eventually be released with freerdp_peer_free().
freerdp_peer_free
freerdp_peer_context_new / freerdp_peer_context_new_ex
rdpContext for the peer and invokes the ContextNew callback. freerdp_peer_context_new_ex allows supplying a pre-built settings object. Must be called before peer->Initialize().
freerdp_peer_context_free
ContextFree. Called automatically by freerdp_peer_free().
Struct: rdp_freerdp_peer
The core peer struct (typedefd as freerdp_peer). Key fields:
rdpContext*
The RDP context. Access settings via
context->settings, update interface via context->update, autodetect via context->autodetect.int
The underlying TCP socket file descriptor.
char[50]
String representation of the client’s address, populated by
freerdp_peer_set_local_and_hostname().BOOL
TRUE when the connection is from a Unix-domain socket (local).BOOL
Set to
TRUE once the low-level connection is established.BOOL
Set to
TRUE after the Activate callback returns successfully.BOOL
Set to
TRUE after NLA or another authentication mechanism completes.size_t
Set this to
sizeof(YourContext) before calling freerdp_peer_context_new() to extend the context with private data.void*
Optional extra data pointer passed unchanged through context lifecycle callbacks.
Initialization Callbacks
psPeerContextNew
freerdp_peer_context_new() after allocating the context. Use this to initialize any fields in your custom context struct. Return FALSE to abort.psPeerContextFree
psPeerInitialize
freerdp_peer_context_new(). Returns FALSE on failure.Event Loop
psPeerGetEventHandle
HANDLE (event) that becomes signalled when the peer has data to process. Use with WaitForSingleObject or WaitForMultipleObjects.psPeerGetEventHandles
events[] with all handles (transport, virtual channels, etc.) that the peer event loop depends on. Returns the number of handles written.psPeerGetReceiveEventHandle
psPeerCheckFileDescriptor
GetEventHandle becomes signalled. Returns FALSE when the connection should be closed.psPeerHasMoreToRead
TRUE if the peer input buffer has unprocessed data. Call CheckFileDescriptor again when this returns TRUE without waiting on the handle.psPeerIsWriteBlocked
TRUE if the send buffer is full. In this case drain it with DrainOutputBuffer before sending more data.psPeerDrainOutputBuffer
> 0 if data remains, 0 when fully drained, < 0 on error.Connection Callbacks
psPeerCapabilities
peer->context->settings here to check what the client supports. Return FALSE to reject.psPeerPostConnect
Activate. Use this to open virtual channels and configure the update pipeline. Return FALSE to abort.psPeerActivate
Input Synchronize PDU, signalling it is ready to receive screen updates. This is the earliest point to begin sending graphics. Return FALSE to abort.psPeerLogon
automatic is TRUE when the connection was already authenticated (e.g. Kerberos SSO), FALSE for RDP/TLS tunnels where credentials arrive here. Return FALSE to deny the connection.psPeerClientCapabilities
Capabilities).psPeerLicenseCallback
LICENSE_CB_COMPLETED to proceed, LICENSE_CB_ABORT to disconnect.Disconnection
psPeerClose
FALSE on error.psPeerDisconnect
Channel I/O
psPeerSendChannelData
psPeerSendChannelPacket
CHANNEL_FLAG_FIRST, CHANNEL_FLAG_LAST, etc.).psPeerReceiveChannelData
psPeerVirtualChannelOpen
flags is WTS_CHANNEL_OPTION_DYNAMIC or similar.Sending Graphics Updates
AfterActivate returns, push screen updates through peer->context->update:
update->SurfaceCommand and compose the RFX payload with rfx_compose_message() (see Codecs).
Minimal Peer Setup Example
The peer
CheckFileDescriptor callback returns FALSE when the client disconnects or a protocol error occurs. Always check the return value and exit the event loop accordingly.