FreeRDP/FreeRDP — pull request #1553 by dpoe (2013-10-22 15:52:42+00:00)
Title: commandline session reconnect

This enables session reconnect via a pair of command-line options: one to print the cookie (in base64 form) and one to reuse the cookie from a previous session. This allows much quicker reconnection after a crash or connection drop. It's "auto-reconnect" without the "auto-". Anthony Tong did some early work in this area.

To use, start your connection with +print-reconnect-cookie. In a subsequent start, use /reconnect-cookie:xxx, where xxx is the cookie from the last session. You still need to provide traditional credentials.

Note this same code could be used for reliable auto-reconnect within the xfreerdp application, but full auto-reconnect requires the xfreerdp application do several things:
1) be very clean about connection, channel, datastructures for shutdown, startup, threads, etc., so that it can shutdown everything cleanly and start a connection anew. And this cleanliness must be maintained as the code grows and gets refactored. (This would probably be good for brokered connections too.)
2) never block in the monitoring thread (such as on socket I/O in a dead connection)
3) interface with the user to tell them what's going on
4) add some code to force occasional traffic from the server, either by the new RDP8.1 heartbeat, refresh_rect, or some other means; so that a dropped connection can be detected

I leave the larger solution to a future exercise.