It's a client-server architecture where clients can upload and download files to and from the server, similar to the FTP protocol.
There are 2 application, a server.exe and a client.exe. The server is the one to receive and send files when requested and the client is the one
who can upload and download files.
Once the server is listening for connections, the clients can connect, upload and download files.
The uploaded files will be saved in Client-Server-FTP\Server\Server\bin\debug\net6.0\files
The downloaded files will be saved in the folder you select.
Both server and client are written in C#.The only difference is that the client is a windows form, meanwhile the server is a console application. It uses socket to communicate and send files.
For each upload, download and list of available files, the client send first a letter so the server can know what the client what. The receive of the
Server is managed with switch-case to redirect the right function based on the letter receive.
To send a file it is first necessary to send the file name.
After that a byte[] containing the lenght of the file is sent so the progress bar know how much
byte need to be received and can display the prpgress based on the bytes received so far.
The actual file is sent in block of 4096 kb. After that a terminator is sent, meaning the sending is over.
Open the server application(exe) that you will find in CLient-Server-FTP\Server\Server\bin\debug\net6.0.
If no errors occurs the console should look like this and is ready to accept connections;
- Client connects to the server:
- Client disconnect from the server:
- Client upload a file:
- Client view the available files for the download:
- Client download a file:
- Open the client application(exe) that you will find in Client-Server-FTP\Client\Client-FTP\bin\Debug.
If no errors occurs the form should look like this and is ready to connect;
Once the client is open and the server is listening you can connect the client, using the ip address, which by default is 127.0.0.1, and the port, default 5000, using the start button.
To be able to see if the connection was successful you can check the text under the progress bar, if it was there would be a text like this
Once you are connected you can upload a file. In order to do so you have to click the browse button select a file and then click the upload button.
You can check the status with the progress bar and the text under.
Once the upload is finished you can see the text:
To download a file you need to click view available files button and then select the file you want to download:
After that you need to click the download button where you can select where the file will be downloaded.
As for the upload, the progress bar will show the process of the download and after the completition of the download it will appar a text.
If you press the Visualizza storico button you can see the operation you did and the possible error that occured.
Feel free to use the ❔ at the right side of each buttons to understand better what they do.
Nome | Autore | Link |
---|---|---|
ProgressBarConsole | DanielSWolf | https://gist.github.com/DanielSWolf/0ab6a96899cc5377bf54 |
Client Interface | Pete Batard | https://github.com/pbatard/rufus |
❌ If multiple clients try to download the same file, only the first one is allowed.
❌ Server console gets a bit ugly when multiple clients try to do different things.