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)
- implement distributed peer to peer Chat application using ring topology and bus/line topology in Java along with theory of approacharrow_forwardWrite a java program to compare the site url with its ip address and print what it returns.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
- 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_forwardWrite a java program that will chat with three threads until taking STOP word input. you must use multithreading along with synchronized method.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
- Brieefly explains the multi-threading idea in Java. Please provide an execution diagram demonstrating the context switching mechanism between the main thread and the peer thread.arrow_forwardUsing Java Programming Language (Java Socket /TCP Programming) Please make a simple messaging program that will allow users to send private messages to other users (not the server). All the users have their usernames and passwords stored in an XML file Users can only send messages to online users Messages to offline users will be stored in a separate XML filearrow_forwardModify the following code to use only ONE message queue for one server and multiple clients Computer Sciencearrow_forward
- Match the statements in the left column with the appropriate architecture in the right column. There is a server that is always on. Processes may request service from other processes or provide service to other processes. There is always a client process and a server process in any communication. HTTP uses this architecture. Hosts are controlled by users and could be up or down unpredictably. Self-scalable. A. Peer-to-peer. B. Neither client-server nor peer-to-peer. C. Client-server or peer-to-peer. D. Client-server. E. TCP/IP architecture.arrow_forwardWrite a Java program using Thread with single Server and Multiple Clients NOTE: Client must be running until Bye message is sent. Server should never stop I need answer question pls one server two clientarrow_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
- 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