This article is senlie original, reproduced Please retain this address: http://blog.csdn.net/zhengsenlie
1. The traditional concurrent server calls fork to derive a sub-process to process each customer
2. The problem with traditional concurrent servers is that it takes CPU time to fork a sub-process at each customer's site.
/* Include serv01 */# include "unp. H "intmain (INT argc, char ** argv) {intlistenfd, connfd; pid_tchildpid; voidsig_chld (INT), sig_int (INT), web_child (INT); len_tclilen, addrlen; struct sockaddr * cliaddr; // 1. use tcp_listen to create a TCP socket --> protocol-independent. Both IPv4 and IPv6 are applicable to 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 a process fork for each customer