How to write a multithreaded server in C (threads, sockets)