What you want is a multi-threaded socket server.
To do this, you need a main thread that opens the socket for listening (and waits for incoming client connections). This should go into the while loop.
, , accept() , , .
, .
, , ( ).
.
, bind(), listen() accept() .