// simple sample codes for multiclient-capable server /* * in your main function, do the create, bind, listen, etc. */ // then start a loop forever listening do { // accept, but do not forget to put exception handling client_socket = accept(listen_socket, , ); if ((child_id = fork()) < 0) { // something wrong, whatever you want to do here close(client_socket); } else { if (child_id == 0) { // Do the client stuff ..., we make a function call one_client_connection(client_socket); // remember to close the client_socket, the server does not need it close(client_socket); } } } while(1); one_client_connection(int client_sock) { /* * do your communication stuff ... */ }