Added support for SSL transport

Additionally fixed TCP message handling, since it needed to work in cases where TCP messages did not arrive as a whole