UNIX Network Programming volume 1 Server programming paradigm 1 concurrent server, requesting a process fork for each customer

Source: Internet
Author: User
Tags sigint signal

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

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.