import java.net.*; import java.io.*; import java.util.*; public class Server{ public static void main(String[] args)throws Exception { try{ Scanner in = new Scanner(System.in); ServerSocket serverSocket = new ServerSocket(5000); Socket socket = serverSocket.accept(); DataInputStream din = new DataInputStream(socket.getInputStream()); DataOutputStream dout = new DataOutputStream(socket.getOutputStream()); String readingLine = in.nextLine(); while(readingLine != "umbrella") { dout.writeUTF(readingLine); //to output from the socket String str = (String) din.readUTF(); //to read from the socket System.out.println("client : " + str); System.out.println("Enter Your Input : "); readingLine = in.nextLine(); } // dout.writeUTF("Hello World from Server!"); // String str = (String) din.readUTF(); socket.close(); serverSocket.close(); } catch(Exception e){ System.out.println(e); } } }