12.36

    check section 11.6 and 12.2.1, combine code pieces together

    code directory: chapter12/code/12.36

    origin tiny server: tiny.h tiny.c

    select echoserver: echoserver.h echoserver.c

    key points:

    • move main loop to main.c file
    • check_clients in echoserver call doit(from tiny server) and close fd

    benchmark it

    1. Running 4s test @ http://localhost:5000
    2. 2 threads and 10 connections
    3. Thread Stats Avg Stdev Max +/- Stdev
    4. Latency 62.72ms 91.68ms 368.55ms 82.94%
    5. Req/Sec 615.27 398.96 1.46k 65.91%
    6. 3649 requests in 4.00s, 816.04KB read
    7. Requests/sec: 911.45
    8. Transfer/sec: 203.83KB