Advertisement
Josif_tepe

Untitled

Apr 22nd, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.io.PrintWriter;
  5. import java.net.ServerSocket;
  6. import java.net.Socket;
  7.  
  8. public class Server {
  9.     public static void main(String[] args) {
  10.         try {
  11.             System.out.println("Cekame klienti");
  12.             ServerSocket serverSocket = new ServerSocket(4567);
  13.             Socket socket = serverSocket.accept();
  14.             System.out.println("konekcijata e uspesna");
  15.             BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  16.             String server_poraka = in.readLine();
  17.             PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
  18.             System.out.println("serverot vika: " + server_poraka);
  19.  
  20.         }
  21.         catch (IOException io) {
  22.             io.printStackTrace();
  23.         }
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement