Computer Systems: Program... -Access
Computer Systems: Program... -Access
3rd Edition
ISBN: 9780134071923
Author: Bryant
Publisher: PEARSON
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
Students have asked these similar questions
Suppose Alice, with a Web-based e-mail account (such as Hotmail or Gmail), sends a message to Bob, who accesses his mail from his mail server using POP3. Discuss how the message gets from Alice’s host to Bob’s host. Be sure to list the series of application-layer protocols that are used to move the message between the two hosts.
Suppose a user has two browser applications active at the same time and suppose that the applications are accessing the same server to retrieve HTTP documents at the same time. How does the server tell the difference between two applications?
build a TCP-based chat messenger with a graphical user interface using java
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education