Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CAN USE JAVA OR C/C++ Need to make code for a server and client. ALL info found below: ---- 3 Specifications Your web server should

CAN USE JAVA OR C/C++

Need to make code for a server and client.

ALL info found below:

image text in transcribed

----

image text in transcribed

3 Specifications Your web server should accept incoming connection requests. It should then look for the GET request and pick out the name of the requested file. Note that a GET request from a real www client may have several lines of optional information following the GET. These optional lines, though, will be terminated by a blank line i.e., a line containing zero or more spaces, terminated by a n' (carriage return then newline characters). Your server should first print out the received GET command as well as any optional lines following the GET (and preceding the empty line). The server should then respond with the line, this is a very simple version of the real HTTP reply message: HTTP/1.0 200 OK (data, data, ...., data} followed by a blank line (i.e., a string with only blanks, terminated by a' n'). The server should then send the contents of the requested document, close the socket created by the accept() function and wait to accept a new connection request. If the document is not found, the server should respond with as would a real http server): HTTP/1.0 404 Not Found 3.1 Server Side Pseudo Code while true: do Listen for connections Accept new connection from incoming client and delegate it to worker thread/process. Parse HTTP/1.0 request Ensure well-formed request (return error otherwise) Determine if target file exists and if permissions are set properly (return error otherwise) Transmit contents of file to connect (reads from the file and writes on the socket) Close the connection end while 3.2 Notes . There are different types of HTTP status codes, you're only required to handle 404 and 200. . You will want to become familiar with the interactions of the following Java Classes: Server Socket, Socket. For C, we need to use socket(), select(), listen(), accept(), connect(). Command to run the server: ./my_server port_number You are supposed to handle HTML, TXT and images. 4 Part 2: HTTP Web Client 4.1 Specifications Your web client must read and parse a series of commands from the standard input. For this assignment, only the GET command is required to be handled. The get command syntax should be as follows: GET file-name host-name (port-number) Note that the port number is optional. If it is not specified, use the default HTTP port number, 80. In response to a GET operation, the client must open a connection to an HTTP server on the specified host listening on the specified (or default) port number. It must then transmit a legal HTTP GET request to request the file specified. It must display the file and then store it in the local directory i.e., the directory from which the client program was run). The client should shut down when reaching the end of file. 4.2 HTTP commands sent by the Client: This is a real HTTP GET command example: GET /somedir/page.html HTTP/1.0 Host: www.someschool.edu Connection: close User-agent: Mozilla/4.0 Accept: text/html, image/gif, image/jpeg Accept-language:fr (extra carriage return + line feed) In this assignment and for simplicity, performing a GET operation with a server is done by sending two lines across a socket connection that has been established with the server. The first line is a string containing the key word GET, followed by a file name, followed by the version of HTTP supported by this client. The second line consists only of a newline character. For example, if the client sends the two strings: GET /index.html HTTP/1.0 to an http server, the http server will respond with the file /index.html. You don't need host-name or port- number here as the connection is already established. 4.3 Client Side Pseudo code while more GET operation exists do Create a TCP connection with the server Wait for permission from the server Send next GET requests to the server Receives data from the server Close the connection end while 4.4 Notes You can choose between having an input file that contains a number of GET requests, or let the input file contain only one GET operation for a file (Which contains other GET requests) at the server and upon receipt of the file, you parse it and handle the GET operations one by one, and you keep doing this till you receive the last file which is empty. Command to run the client: ./my_client server_ip port_number . Your client program should use the reliable stream protocol, i.e., TCP

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

$100 is what percent less than $110?

Answered: 1 week ago

Question

=+CASE 2. Sr. By the second part of (7.30), A(r,s) =qA(2r-1,2s-1)0.

Answered: 1 week ago

Question

Organize and support your main points

Answered: 1 week ago

Question

Move smoothly from point to point

Answered: 1 week ago

Question

Outlining Your Speech?

Answered: 1 week ago