Listener thread is maintained at server side :
I have Implemented as:
/* specify queue */
listen\(sockfd, 5\);
while \(1\) \{
clilen = sizeof\(cli_addr\);
newsockfd = accept\(sockfd,
\(struct sockaddr *\) &cli_addr, &clilen\);
if \(newsockfd < 0\)
error\("ERROR on accept"\);
/* create a new thread to process incoming request */
printf\("Create thread \\n"\);
ret = pthread_create\(&thr, NULL, dostuff, \(void *\)newsockfd\);
//printf\("ret=%d\\n", ret\);
pthread_detach\(thr\);
/* the server is now free to accept another socket request */
\} /* end of while */
Is it correct?