Question
You can learn a lot about the design of client-server protocols by reviewing the implementation of one. And you can develop an even greater understanding
You can learn a lot about the design of client-server protocols by reviewing the implementation of one. And you can develop an even greater understanding by extending or updating that implementation.
For this Assignment, you will modify an existing client-server protocol to implement the Internets finger protocol.
To prepare:
Download the existing program contained in Week6_Echo.zip. This file unzips into a NetBeans project that includes the source code for two Java programs, a client program, and a server program. The two programs implement the Internets echo protocol.
Start up NetBeans. Open the Week6_Echo project you just downloaded and unzipped.
By Day 7, modify the client and the server so that they implement the Internets finger protocol. The response from the server does not need to reflect actual user data, but you must base the response on the name provided in the clients request.
Save and submit your Assignment as a ".zip" file.
Retain your implementation, as you will be using it again in Week 7.
Please provide answer in a NetBeans project. Original project can be provided if needed.
echoclient.java:
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress;
public class EchoClient {
public static void main(String[] args) throws IOException {
int b;
Socket socket = new Socket(args[0], 7000); InputStream input = socket.getInputStream(); OutputStream output = socket.getOutputStream();
System.out.println("The socket is connected the server."); System.out.println("... local socket address is " + socket.getLocalSocketAddress()); System.out.println("... remote socket address is " + socket.getRemoteSocketAddress());
output.write(args[1].getBytes()); socket.shutdownOutput();
while (true) { b = input.read(); if (b == -1) { break; } System.out.print((char) b); } System.out.println();
socket.close(); } }
echoserver.java:
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket;
public class EchoServer {
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = new ServerSocket(7000);
System.out.println("The ITEC 6120/8120 Echo Server is now ready!");
while (true) { Socket socket = serverSocket.accept(); System.out.println("Accepted an echo request"); System.out.println("... local socket address " + socket.getLocalSocketAddress()); System.out.println("... remote socket address " + socket.getRemoteSocketAddress());
InputStream input = socket.getInputStream(); OutputStream output = socket.getOutputStream();
while (true) { int b = input.read(); if (b == -1) break; output.write(b); }
socket.close(); }
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started