Advertisement
fahimkamal63

My client

Aug 15th, 2019
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. /**
  2.  * My client
  3.  * Date : 28.07.198
  4.  */
  5. package Socket;
  6. import java.net.*;
  7. import java.io.*;
  8.  
  9. public class Myclient {
  10.     public static void main(String[] args) throws Exception{
  11.         Socket s = new Socket("localhost", 3333);
  12.         DataInputStream din = new DataInputStream(s.getInputStream());
  13.         DataOutputStream dout = new DataOutputStream(s.getOutputStream());
  14.        
  15.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  16.        
  17.         String str = "", str2 = "";
  18.         while(!str.equals("stop")){
  19.             str = br.readLine();
  20.             dout.writeUTF(str);
  21.             dout.flush();
  22.            
  23.             str2 = din.readUTF();
  24.             System.out.println("Server says: " + str2);
  25.         }
  26.         dout.close();
  27.         s.close();
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement