Thread spawning for tcp connection