This activity will enable you to apply what you learn during this course

computer science

Description

This activity will enable you to apply what you learn during this course. In this assignment you will write, test, and debug a Java program or any other programming language you prefer that functions as an echo server.

When the program starts, it should open a server socket to listen for connections on port 8081. When a client connection is received, the program should create a new thread to handle the connection. The worker thread should read a single line of text from the connection (up to the newline character), write the line back to the client connection, and close the connection. The program should accept new connections until it is forcibly shut down. The program must be multi-threaded and be capable of responding to multiple requests at once.

Helpful Hints:

  • Use the java.net.ServerSocket class to open a port and listen for new connections (see chapter 3 of the textbook for more information).
  • Use the java.net.ServerSocket.accept() method to accept a new client connection.
  • You can read from and write to the data streams in java.net.ServerSocket.getOutputStream() and java.net.ServerSocket.getInputStream() just as if they were files or standard input/output.

Submission Guidelines:

In a Word document, paste screenshots of your code and successful execution. Combine the Word document, your entire solution, and any necessary files together and submit as a single ZIP file.

Use the American Psychological Association (APA) style for writing your assignment.


Related Questions in computer science category