EBK COMPUTER SYSTEMS
EBK COMPUTER SYSTEMS
3rd Edition
ISBN: 8220101459107
Author: O'HALLARON
Publisher: YUZU
Expert Solution & Answer
Book Icon
Chapter 12, Problem 12.36HW

Explanation of Solution

Implementation of a concurrent prethreaded version of the TINY web server:

For code “echoservers.c” and “echoservers.h” file:

Use section 12.2.1 code.

For code “tiny.c” and “tiny.h”:

Use section 11.6 code.

sample.html:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<title>Home</title>

</head>

<body>

  Tiny server Example

</body>

</html>

main.c:

#include <stdio.h>

#include "csapp.h"

#include "echoservers.h"

//Main function

int main(int argc, char **argv)

{

  //Declare variable

  int listenfd, connfd;

  socklen_t clientlen;

  struct sockaddr_storage clientaddr;

  static pool pool;

/* If the arguments does not contain two arguments, then display the below statement */

  if (argc != 2)

  {

    fprintf(stderr, "usage: %s <port>\n", argv[0]);

    fprintf(stderr, "use default port 5000\n");

    listenfd = Open_listenfd("5000");

  }

  //Otherwise call Open_listenfd function

  else

  {

    listenfd = Open_listenfd(argv[1]);

  }

  //Then call the init_pool function

  init_pool(listenfd, &pool);

  //Check condition

  while (1)

  {

/* Wait for listening or connected descriptor(s) to convert ready */

    pool.ready_set = pool.read_set;

pool.nready = Select(pool.maxfd+1, &pool...

Blurred answer
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY