Write a Client-Server application using TCP Socket where client can send message and server respond with the reverse of them

Question: Write a Client-Server application using TCP Socket where client can send message and server respond with the reverse of them.
Write a Client-Server application using TCP Socket where client can send message and server respond with the reverse of them


package MyClient;
import java.io.*;
import java.net.*;
public class MyClient
{
public static void main(String[] args) throws IOException
{
    try
    {
        Socket s = new Socket("localhost",6666);
        DataOutputStream dout = new DataOutputStream(s.getOutputStream());
        dout.writeUTF("GUJARAT TECHNOLOGICAL UNIVERSITY");
        dout.flush(); 
    }
    catch(Exception e)
    {
        System.out.println(e);
    }
}
}

MyServer.java:
package MyServer;
import java.io.*;
import java.net.*;
public class MyServer
{
   public static void main(String[] args) throws IOException
   {
        ServerSocket ss=new ServerSocket(6666);
 Socket s=ss.accept();
        DataInputStream dis=new DataInputStream(s.getInputStream());
 String str=(String) dis.readUTF();
        StringBuffer buffer = new StringBuffer(str);
        buffer.reverse();
        System.out.println(buffer);
   }
}

Output:
ajava output



ajava output

Download the Android app to get all Government Job Notifications on your Mobile.
Download Now
Important: Please always Check and Confirm the above details with the official Advertisement / Notification.
Previous Post Next Post