If you want to look at some C++ code for a thread that handles TCP, on either the server or client side, here
] is an example. Start in the
function on line 332. This has been tested under load on Windows. The comments in its header
] should also help.