Advertisement
didito33

Client

Nov 28th, 2021
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package Socket;
  2. import java.io.IOException;
  3. import java.io.PrintStream;
  4. import java.net.Socket;
  5. import java.util.InputMismatchException;
  6. import java.util.Scanner;
  7.  
  8. public class Client {
  9. public static void main(String args[]) throws IOException {
  10. int number;
  11. Socket s = new Socket("127.0.0.1", 1211);
  12. Scanner scan = new Scanner(System.in);
  13. Scanner scan2 = new Scanner(s.getInputStream());
  14. PrintStream printout = new PrintStream(s.getOutputStream());
  15. System.out.print("Enter some Value: ");
  16. try {
  17. number = scan.nextInt();
  18. printout.println(number);
  19. String input = scan2.nextLine();
  20. String input2 = scan2.nextLine();
  21. String input3 = scan2.nextLine();
  22.  
  23. System.out.println(input);
  24. System.out.println(input2);
  25. System.out.println(input3);
  26. //PRINTQ 3 REDA
  27. } catch (InputMismatchException e) {
  28. System.out.println("Enter a correct value");
  29. } finally {
  30. if (s != null)
  31. s.close();
  32. if (scan != null)
  33. scan.close();
  34. if (scan2 != null)
  35. scan2.close();
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement