adding support for length prefixed json on the client socket

As @portertech & I agreed on IRC, I am adding support for length prefixed JSON to the client socket while keeping the existing behavior as it is.

Thanks,
praddy
Shouldn't it be a fatal error if the client says "I'm about to send you 10 bytes." and then goes ahead and sends 17?