[Newb alert]
i wish to start a server that will allow multipile connections at once at first i thout about forking but then i realized that it will consume alot of resorses.
so i started googling about threads and i thout that it is wiser to use threads for this condition .
as from example on socket for linux tutorial
what will be the apropreate code with treads ?Code:while (1) { newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); if (newsockfd < 0) error("ERROR on accept"); pid = fork(); if (pid < 0) error("ERROR on fork"); if (pid === 0) { close(sockfd); dostuff(newsockfd); exit(0); } else close(newsockfd); } /* end of while */
P.s.
my server will get a string from a uniqe client accses a database retrive a aporeate data from database
start sevral function on this data
and return an answer to the client



LinkBack URL
About LinkBacks


