C++ server code

Latest master merged in. We should discuss the layout of the code.
what is the reason for passing this in as `size_t` and not `int`