This document is intended to explain xrdp server design.

Many connections, all capable of running different modules
one connection could be using a vnc connection
one could be running a custom app made for xrdp
one could be running a X11 session
clients control the screen size and color depth

all controlled by a cofiguaration file.

you can create a lib or use a lib with your executable that talks
to xrdp server.

------              ----------
-xrdp---linked-------mylib.so-                session 1
------              ----------
   |
   |                -------------------------
   |----unix socket--myapp linked to libxrdp- session 2
   |                -------------------------
   |
   |                -----------
   |----linked-------mylib2.so-               session 3
                    -----------

Any of the above sessions can repeat or have different session
numbers or not even be used.
If a session is disconnected, all that changes is the rdp connection
is lost, the session remains.

For X11, start the XServer after the user is
authenticated.  First check for the next available X11 display,
create a user session, start the XServer and set the DISPLAY enviromenet
variable.