Advertisement
Josif_tepe

Untitled

Mar 31st, 2022
754
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None
  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(1234);
  13.             Socket socket = serverSocket.accept();
  14.             System.out.println("Konekcijata e uspesna!");
  15.             BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  16.             String serverPoraka = input.readLine();
  17.             PrintWriter output = new PrintWriter(socket.getOutputStream(), true);
  18.             System.out.println("Serverot vika: " + serverPoraka);
  19.         }
  20.         catch (IOException ex) {
  21.  
  22.         }
  23.     }
  24. }
  25.  
Advertisement
RAW Paste Data Copied
Advertisement