Preparations to threaded TCP server.

NOTE: not usable yet.