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 solutionChapter 12 Solutions
Computer Systems: Program... -Access
- Suppose Alice with a Web-based e-mail account (such as Gmail) sends it 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 movethe message between the two hosts.arrow_forwardAs an example, examine two realistic HTTP Response Codes that you are familiar with and their function in relation to the associated HTTP Commands you are aware of on the MIT Website (s).arrow_forwardWrite a simple multithreaded web server in C#. Regardless of the page requested, the server should respond with an HTML page displaying just the words “hello word”arrow_forward
- Suppose you have a web server that can handle 500 requests per second. If each request takes an average of 50 milliseconds to process, what is the maximum number of concurrent requests that the server can handle without overloading?arrow_forwardTracing the steps methodology, to write a java program, where the server side receive a TCP connection from client side, and then the client upload on the server the following files using FTP: 1- Image file named “ Myimage.jpg” if the client upload <image file>.2- Text file named “Mytext.txt” if the client upload <text file>.arrow_forwardimplement distributed peer to peer Chat application using ring topology and bus/line topology in Java along with theory of approacharrow_forward
- Discuss the various communication models in distributed systems, such as synchronous, asynchronous, and remote procedure call (RPC).arrow_forwardSuppose user has two browser applications active at the same time, and suppose that the two applications are accesing the same server to retrieve HTTP documents at the same time. How does tge server tell the difference between two applications ?arrow_forwarduse this link to simulate http://automatonsimulator.com/arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education