almost finished sockets with threads