Advertisement
Eternoseeker

Client side STOP

Apr 10th, 2023
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | Source Code | 0 0
  1. import java.net.*;
  2. import java.io.*;
  3.  
  4. public class Client {
  5.     public static void main(String args[])throws Exception{
  6.         Socket s = new Socket("localhost", 3332);
  7.         DataInputStream din = new DataInputStream(s.getInputStream());
  8.         DataOutputStream dout = new DataOutputStream(s.getOutputStream());
  9.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  10.  
  11.         String str = "", str2 = "";
  12.         while(!str.equals("stop")){
  13.             str = br.readLine();
  14.             dout.writeUTF(str2);
  15.             dout.flush();
  16.             str2 = din.readUTF();
  17.             System.out.println("Server says: " + str2);
  18.         }
  19.         dout.close();
  20.         s.close();
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement