Advertisement
CSenshi

OOP - Statuses (ClientSide)

Jul 1st, 2019
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. package f2015.ex3;
  2.  
  3. import java.io.*;
  4. import java.net.Socket;
  5. import java.util.Scanner;
  6.  
  7. public class Client {
  8.  
  9.     public static void main(String[] args) {
  10.         try {
  11.             Socket s = new Socket("127.0.0.1", 8080);
  12.             Scanner scanner = new Scanner(System.in);
  13.  
  14.             InputStream is = s.getInputStream();
  15.             InputStreamReader isr = new InputStreamReader(is);
  16.             BufferedReader br = new BufferedReader(isr);
  17.  
  18.             OutputStream os = s.getOutputStream();
  19.             PrintWriter pw = new PrintWriter(os, true);
  20.  
  21.             while (true) {
  22.                 String req = scanner.nextLine();
  23.                 pw.println(req);
  24.                 if(!req.contains(":"))
  25.                     System.out.println(br.readLine());
  26.             }
  27.         } catch (IOException e) {
  28.             e.printStackTrace();
  29.         }
  30.  
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement