As I developed the Java client, and then later a Universal Windows Program (read this as "Windows phone app") I find myself encoding and decoding the network protocol over and over. My solution is to use JSON on the wire.
For the server I grabbed the debian packages for libJsonCpp and hooked them into the makefile. Then I added a new thread called JsonThread that started as a direct copy of the network thread. I added the new thread to the configuration file and gave it a new socket number so the pair of them would coexist in the application. Then started to look at the get devices command.
The initial effort was to make the return stream json compliant, then I made the input stream understand json, This was relatively easy as the JsonCpp has pretty useful documentation, and of course you can always look at the source code!
Now I need to look at all of the other commands that can be sent over the wire, and convert them. Then I can look at the clients so that eventually I will be able to remove the only network thread.