Citrix offers a mechanism called Virtual Channels which are specifically designed for communication between client and server:
A Citrix virtual channel is a bi-directional error-free connection used for the exchange of generalized packet data between a Citrix host for online delivery (XenApp or XenDesktop) and the Citrix Receiver online plug-in. For example: sound, graphics, client drive mapping, and printing are just a few of the virtual channels written by Citrix. The Citrix Virtual Channel Software Development Kit (VCSDK) allows software engineers to write both host-side applications and receiver-side drivers to support additional virtual channels using the Citrix ICA protocol. The host-side virtual channel applications run on XenApp or XenDesktop, and the client-side portion of the virtual channel runs on the local device where Citrix Receiver resides. This SDK provides support for writing new virtual channels for the Win32 and Windows CE versions of the online plug-ins for Citrix Receiver. See the accompanying documentation for detailed information about the client versions supported.
Microsoft offers a similar Virtual Channel implementation for RDS: Virtual channels are software extensions that can be used to add functional enhancements to a Remote Desktop Services application. Examples of functional enhancements might include: support for special types of hardware, audio, or other additions to the core functionality provided by the Remote Desktop Services Remote Desktop Protocol (RDP)