Advertisement
Josif_tepe

Untitled

Apr 22nd, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3. import java.io.PrintWriter;
  4. import java.net.ServerSocket;
  5. import java.net.Socket;
  6.  
  7. public class Server {
  8. public static void main(String[] args) {
  9. try {
  10. System.out.println("waiitng for clients");
  11. ServerSocket ss = new ServerSocket(9806);
  12. Socket socket = ss.accept();
  13. System.out.println("Connection established");
  14. BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  15. String s = in.readLine();
  16. PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
  17. out.println("Server says: " + s);
  18. }
  19. catch (Exception e) {
  20. e.printStackTrace();
  21. }
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement