import java.io.*; import java.net.*; public class Client1 { public static void main(String[] args) { try{ Socket s = new Socket("Localhost",6666); DataOutputStream dout = new DataOutputStream(s.getOutputStream()); DataInputStream din = new DataInputStream(s.getIntputStream()); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); dout.writeUTF("Hello Server"); dout.flush(); dout.close(); s.close(); String str,str2; while(!str.equals("Stop")){ str=br.readline(); dout.writeUTF(str); dout.flush(); str2=din.readUTF(); System.out.println("Server says :"+str2); } dout.close(); s.close(); }catch(Exception e){ System.out.println("Handeled"); } } }