
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...

Want to see the full answer?
Check out a sample textbook solution
Chapter 12 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning
- Principles of Information Systems (MindTap Course...Computer ScienceISBN:9781305971776Author:Ralph Stair, George ReynoldsPublisher:Cengage LearningLINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.Computer ScienceISBN:9781337569798Author:ECKERTPublisher:CENGAGE LPrinciples of Information Systems (MindTap Course...Computer ScienceISBN:9781285867168Author:Ralph Stair, George ReynoldsPublisher:Cengage Learning





