Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Written in java, compiled in linux terminal An echo server echoes back whatever it receives from a client. For example, if a client sends the

Written in java, compiled in linux terminal

An echo server echoes back whatever it receives from a client. For example, if a client sends the server the string Hello there! I am the client., the server will respond with Hello there! I am the server.

Write an echo server (you can use the Java networking API). This server will wait for a client connection using the accept() method. When a client connection is received, the server will loop, performing the following steps: 1. Read data from the socket into a buffer. 2. Write the contents of the buffer back to the client. The server will break out of the loop only when it has determined that the client has closed the connection.

Hints: the date server of Figure 1 uses the java.io.BufferedReader class. BufferedReader extends the java.io.Reader class, which is used for reading character streams. However, the echo server cannot guarantee that it will read characters from clients; it may receive binary data as well. The class java.io.InputStream deals with data at the byte level rather than the character level. Thus, your echo server must use an object that extends java.io.InputStream. The read() method in the java.io.InputStream class returns 1 when the client has closed its end of the socket connection.

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_2

Step: 3

blur-text-image_3

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

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

1. What is meant by Latitudes? 2. What is cartography ?

Answered: 1 week ago

Question

What is order of reaction? Explain with example?

Answered: 1 week ago

Question

4. What actions should Bouleau & Huntley take now?

Answered: 1 week ago