UNIX Network Programming Volume 1 server Programming Paradigm 1 Concurrent server, requesting fork a process for each customer

Source: Internet
Author: User
Tags sigint signal

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.