Java application is to create a simple client-server applicationusing the Java ServerSocketfor the server and the Java Socketforthe client. You’ll be creating a simple echo serverwhich means whatever message the client sends the server, theserver simply echo’s it back to the client.
Answer
MyClient.java
import java.net.*;
import java.io.*;
class MyClient {
public static void main(String args[]) throwsException {
Socket s = new Socket(“localhost”,1212);
DataInputStream din = newDataInputStream(s.getInputStream());
DataOutputStream dout = newDataOutputStream(s.getOutputStream());
BufferedReader br = newBufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter messageto send it server: “);
String str = br.readLine();
dout.writeUTF(str);
dout.flush();
String str2 = din.readUTF();
System.out.println(“Server says: