Advertisement
fevzi02

Untitled

Feb 6th, 2023
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. package labSK;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6. import java.net.Socket;
  7.    
  8.     public class Klient {
  9.         public static final String HOST = "127.0.0.1";
  10.         public static final int PORT = 2020;
  11.         public static void main(String[] args) {
  12.                 try {
  13.                     System.out.println("Устанавливаем соединение с "+HOST+" по порту " + PORT);
  14.                     Socket socket = new Socket(HOST, PORT);
  15.                     System.out.println("Соединение установлено");
  16.                    
  17.                     DataInputStream input = new DataInputStream(socket.getInputStream());
  18.                     DataOutputStream output = new DataOutputStream(socket.getOutputStream());
  19.                    
  20.                     int start = input.readInt();
  21.                     int stop = input.readInt();
  22.                      
  23.                     System.out.println(start + "/" + stop);
  24.                    
  25.                     for (int startA = start; startA <= stop; startA++) {
  26.                         if (startA % 11 == 0 && startA % 13 == 0 && startA % 17 == 0 && startA % 19 == 0) {
  27.                             output.writeInt(startA);
  28.                             }
  29.                     }  
  30.                     output.writeInt(-127);
  31.  
  32.  
  33.                     System.out.println("Закрываем сокет");
  34.                     socket.close();
  35.                     output.close();
  36.                     input.close();
  37.                    
  38.                     } catch (IOException e) {e.printStackTrace();}
  39.         }
  40.     }  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement