Skip to content

SamDorn/Client-Server-FTP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Client-Server-FTP C#

What is it?

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.

What does it do?

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.

How does it work?

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.

How to use it

Server

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;

immagine

Events

  1. Client connects to the server:
    immagine
  2. Client disconnect from the server:
    immagine
  3. Client upload a file:
    immagine
  4. Client view the available files for the download:
    immagine
  5. Client download a file:
    immagine

Client

  1. 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;

    immagine

Connection

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.
immagine

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

immagine

Upload

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.

immagine

You can check the status with the progress bar and the text under.

immagine

Once the upload is finished you can see the text:

immagine

Download

To download a file you need to click view available files button and then select the file you want to download:

immagine

After that you need to click the download button where you can select where the file will be downloaded.

immagine

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.

immagine

History

If you press the Visualizza storico button you can see the operation you did and the possible error that occured.

immagine

immagine

Feel free to use the ❔ at the right side of each buttons to understand better what they do.

Credits

Nome Autore Link
ProgressBarConsole DanielSWolf https://gist.github.com/DanielSWolf/0ab6a96899cc5377bf54
Client Interface Pete Batard https://github.com/pbatard/rufus

Known bugs

❌ 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.

About

client-server architecture to upload and download files via socket

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages