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: A Programmer's Perspective (3rd Edition)
- write a Client java program that communicates with a Server (host).arrow_forwardBelow is example simulation based on Cisco Packet Tracer! Try to make an interconnection between 3 pieces of network that are connected to a router. Innetwork-1 has a DNS Server and 1 workstation, on network-2 there is an HTTP Server(.com domain) and 1 work station, on network-3 there is an HTTP Server(on the domain .com) and 1 work station. Do such a configuration so that each work station can access the existing server services on the three those networks?arrow_forward- Consider another carelessly written Web application, which uses a servlet that checks if there was an active session, but does not check if the user is authorized to access that page, instead depending on the fact that a link to the page is shown only to authorized users. What is the risk with this scheme? (There was a real instance where applicants to a college admissions site could, after logging into the Web site, exploit this loophole and view information they were not authorized to see; the unauthorized access was however detected, and those who accessed the information were punished by being denied admission.)arrow_forward
- When a Java virtual machine (JVM) is running, a thread can only run one method at a time. Do you have any proof to back up what you think?arrow_forwardA Java virtual machine (JVM) can only run one method at a time on a thread. Do any facts back up what you think you know?arrow_forwardTake a look at two real-world HTTP response codes on the MIT website, for instance, and consider how they relate to the HTTP commands they are linked with (s).arrow_forward
- Implement a Socket based Remote C compiler. NEED THE PROGRAM IN JAVA. The JAVA program will take a C program (from a txt file) as input, send it to the server to compile & execute it, and return it to the client. In other words,The client will write or chose a C program which will be copied to the server, compiled and executed in the server machine and return the result back to the client.arrow_forwardWrite a multi-threading program to print odd number using one thread and even number using other. Asap.arrow_forwardUSING JAVA (Java Socket /TCP Programming) Create a chat/messaging application that has the following functionalities/features: Broadcast message (to all users) Private message to only one message (established usernames are stored in an XML file)arrow_forward
- Write a JAVA program to print X, Y and Z multiplication tables (multiplication table from 1 to 10) using multithreading, where X,Y and Z are three integer numbers. Create three threads to print three multiplication tables and use thread synchronization to print one multiplication table at a time completely without interruption.arrow_forwardConsider the thread hierarchy below: P2 P1 P3 P2 will print "P2", P3 will print “P3" and P1 will print "P1". The output should be in the order P1, P2, P3. Note: P1 is the parent of P2 and P1 is the parent of P3. Write a multithreading program in JAVA.arrow_forwardWe previously said that there may be no more than one active method inside of each thread that is currently running in the JVM at any one time. What gives you reason to think that this is true?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