This article is Senlie original. Reprint please keep this address:Http://blog.csdn.net/zhengsenlie
1. Traditional concurrent server call fork derives a child process to process each customer
2. The problem with traditional concurrent server is that it takes more CPU time to fork a sub-process per customer site.
/* Include SERV01 */#include "unp.h" intmain (int argc, char **argv) {INTLISTENFD, connfd;pid_tchildpid;voidsig_chld (int) , Sig_int (int), web_child (int), Socklen_tclilen, addrlen;struct sockaddr*cliaddr;//1. Use Tcp_listen to create TCP Sockets--Protocol independent. IPV4 and IPV6 are applicable if (argc = = 2) LISTENFD = Tcp_listen (NULL, argv[1], &addrlen), else if (argc = = 3) LISTENFD = Tcp_listen ( ARGV[1], argv[2], &addrlen) elseerr_quit ("Usage:serv01 [
UNIX Network Programming Volume 1 server Programming Paradigm 1 Concurrent server, requesting fork a process for each customer