Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROGRAM 1: This is a programming assignment in Java. Write a simple HTTP client and a separate HTTP server application in Java. As soon as

image text in transcribed

PROGRAM 1: This is a programming assignment in Java. Write a simple HTTP client and a separate HTTP server application in Java. As soon as the client connects, the server will send a html or text file which is between 5 to 10K bytes in size. Close the connection once the file is transmitted Make sure the files are named differently on the client and server side. . You must use the Java socket class. DO NOT implement the server handling multiple requests at the same time (multi-threading). * Implement output messages that show the flow through each method (e.g "Connected to server" or "Receiving message from server", etc) Submit: 1. 2. Source code and sample output of the file transfer (both client and server) Create the Java code and compile it. Run it on your own machine with a port number specified in the command line For example, type: java MyServer 25000) If a service is already running on the port you choose, you will get a BindException or a similar exception. USE THE PORTS YOU WERE ASSIGNED 3. In another window, use Telnet as the client program by typing a command telnet localhost 25000 . This will test that the Server application is working 4. Now test using the Java client by typing: java MyClient 25000 HINT: To send and receive data, client and server can use Java streams - e.g. if the data is in ASCII text form, you can read messages with a BufferedReader using readLine(0 and write messages with a PrintStream using println() for example. PROGRAM 1: This is a programming assignment in Java. Write a simple HTTP client and a separate HTTP server application in Java. As soon as the client connects, the server will send a html or text file which is between 5 to 10K bytes in size. Close the connection once the file is transmitted Make sure the files are named differently on the client and server side. . You must use the Java socket class. DO NOT implement the server handling multiple requests at the same time (multi-threading). * Implement output messages that show the flow through each method (e.g "Connected to server" or "Receiving message from server", etc) Submit: 1. 2. Source code and sample output of the file transfer (both client and server) Create the Java code and compile it. Run it on your own machine with a port number specified in the command line For example, type: java MyServer 25000) If a service is already running on the port you choose, you will get a BindException or a similar exception. USE THE PORTS YOU WERE ASSIGNED 3. In another window, use Telnet as the client program by typing a command telnet localhost 25000 . This will test that the Server application is working 4. Now test using the Java client by typing: java MyClient 25000 HINT: To send and receive data, client and server can use Java streams - e.g. if the data is in ASCII text form, you can read messages with a BufferedReader using readLine(0 and write messages with a PrintStream using println() for example

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago