first version of thread + sockets