Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. /* Serverclient */
  2.  
  3. import java.io.*;
  4. import java.net.*;
  5. import java.util.Scanner;
  6.  
  7. public class ServerClient {
  8.  
  9. public static void main(String[] args) {
  10. String recv;
  11. String send;
  12. Socket MyClient;
  13. try {
  14. MyClient = new Socket("localhost", 1337);
  15. BufferedReader input = new BufferedReader(new InputStreamReader(MyClient.getInputStream()));
  16. PrintWriter output = new PrintWriter(MyClient.getOutputStream());
  17. Scanner scanner = new Scanner(System.in);
  18.  
  19. while(true) {
  20. send = scanner.next();
  21. System.out.println(".");
  22. output.println(send);
  23. recv = input.readLine();
  24. System.out.println(recv);
  25. }
  26.  
  27. } catch (IOException e) {
  28. System.out.println(e);
  29. }
  30.  
  31.  
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement