🤬
  • ■ ■ ■ ■ ■ ■
    Projects/4_Server_for_file_transfers/4_Server_for_file_transfers_2.iml
    1  -<?xml version="1.0" encoding="UTF-8"?>
    2  -<module type="JAVA_MODULE" version="4">
    3  - <component name="NewModuleRootManager" inherit-compiler-output="true">
    4  - <exclude-output />
    5  - <content url="file://$MODULE_DIR$">
    6  - <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
    7  - </content>
    8  - <orderEntry type="inheritedJdk" />
    9  - <orderEntry type="sourceFolder" forTests="false" />
    10  - </component>
    11  -</module>
  • ■ ■ ■ ■ ■ ■
    Projects/4_Server_for_file_transfers/README.md
     1 +# Server for file transfers
     2 + 
     3 +## :information_source: technologies used
     4 + 
     5 +* Java 11
     6 + 
     7 +## :information_source: How use?
     8 +```bash
     9 +# Clone the repository
     10 +$ git clone https://github.com/kurogai/100-redteam-projects
     11 + 
     12 +# Enter the repository
     13 +$ cd 100-redteam-projects/4_Server_for_file_transfers
     14 + 
     15 +# Open a terminal and run
     16 +$ cd src/com/server/ && java Server.java
     17 + 
     18 +# Open a new terminal and run
     19 +$ cd src/com/client/ && java Client.java
     20 +```
     21 + 
     22 +## Developer
     23 + 
     24 +[<img src="https://avatars.githubusercontent.com/u/32443720?v=4" width=115 > <br> <sub> Augusto Savi </sub>](https://github.com/AugustoSavi) |
     25 +| :---: |
     26 + 
  • Projects/4_Server_for_file_transfers/out/production/4_Server_for_file_transfers_2/com/exemple/Client$1.class
    Binary file.
  • Projects/4_Server_for_file_transfers/out/production/4_Server_for_file_transfers_2/com/exemple/Client.class
    Binary file.
  • Projects/4_Server_for_file_transfers/out/production/4_Server_for_file_transfers_2/com/exemple/Server.class
    Binary file.
  • ■ ■ ■ ■ ■ ■
    Projects/4_Server_for_file_transfers/src/com/exemple/Client.java Projects/4_Server_for_file_transfers/src/com/client/Client.java
    1  -package com.exemple;
     1 +package com.client;
    2 2   
    3 3  import javax.swing.*;
    4 4  import java.awt.*;
    skipped 3 lines
    8 8  import java.io.FileInputStream;
    9 9  import java.net.Socket;
    10 10   
    11  -import static javafx.application.Platform.exit;
    12  -
    13 11  public class Client {
    14 12   private static DataOutputStream dataOutputStream = null;
    15 13   private static DataInputStream dataInputStream = null;
    16 14   private static String HOST= "localhost";
     15 + private static Integer PORT= 5000;
    17 16   
    18 17   public static void main(String[] args) {
    19 18   while (true) {
    skipped 13 lines
    33 32   int i = file.showSaveDialog(null);
    34 33   if (1 == i) {
    35 34   System.out.println("Arquivo não informado");
    36  - exit();
    37 35   break;
    38 36   } else {
    39  - Socket socket = new Socket(HOST, 5000);
     37 + Socket socket = new Socket(HOST,PORT);
    40 38   
    41 39   dataInputStream = new DataInputStream(socket.getInputStream());
    42 40   dataOutputStream = new DataOutputStream(socket.getOutputStream());
    skipped 2 lines
    45 43   sendFile(arquivo.getPath());
    46 44   dataInputStream.close();
    47 45   dataInputStream.close();
     46 + socket.close();
    48 47   }
    49 48   } catch (Exception e) {
    50 49   e.printStackTrace();
    skipped 22 lines
  • ■ ■ ■ ■ ■ ■
    Projects/4_Server_for_file_transfers/src/com/exemple/Server.java Projects/4_Server_for_file_transfers/src/com/server/Server.java
    1  -package com.exemple;
     1 +package com.server;
    2 2   
    3 3  import java.io.DataInputStream;
    4 4  import java.io.DataOutputStream;
    skipped 4 lines
    9 9  public class Server {
    10 10   private static DataOutputStream dataOutputStream = null;
    11 11   private static DataInputStream dataInputStream = null;
     12 + private static Integer PORT= 5000;
    12 13   
    13 14   public static void main(String[] args) {
    14 15   while (true){
    15  - try(ServerSocket serverSocket = new ServerSocket(5000)){
    16  - System.out.println("listening to port:5000");
     16 + try(ServerSocket serverSocket = new ServerSocket(PORT)){
     17 + System.out.println("listening to port: " + PORT);
    17 18   Socket clientSocket = serverSocket.accept();
    18 19   System.out.println(clientSocket+" connected.");
    19 20   
    skipped 28 lines
Please wait...
Page is in error, reload to recover