Console application realized during the first year of the Master of Science, at the Polytechnic University of Turin.
It’s about a CLI (Command Line Interface) application, written entirely in C, that simulates a FTP communication (from this, the project name, TFTP, e.g. Trivial FTP) among a server and one or more clients.
The project has been compiled, executed and tested on:
– O.S.: GNU/Linux Ubuntu 10.04 – Lucid Lynx
– Compiler: gcc-4.4.3
The overall number of code lines is about 2000.
Clients and server communicate by using UDP protocol for file exchange.
In particular, for each client, the following operations has been provided:
- CONNECT: the client, known the server address to log on and the (fixed) port the server itself is waiting on, launches the following command:
./client <server address> <server port>
During execution, the client initializes a socket and establishes a pseudo-connection to the server; depending on parameters, it sends a standard character (to notify server of its presence) and waits for a new port, chosen by the server, necessary to continue with transfer operations. If the server is occupied or not existent, a timeout is triggered and the client terminates its execution. When a new port is received, the client can proceed in launching one of the following commands;
- UPLOAD: a client can request the server to upload a file, through this command:
UP <filename>
When the client receives a confirmation, it splits the file in blocks of a certain size; when the transfer is terminated, the server communicates it to the client;
- DOWNLOAD: a client can request the server to download a file, through this command:
DOWN <filename>
Once verified file existence into the server, it accomplishes data block sending;
- QUIT: the client can interrupt communication at whatever time, through this command:
QUIT
The server consists of four instances of pre-forked processes, waiting on a given port, passed from command line:
./server <port>
When a client sends a character, one of the processes accepts the [pseudo]connection request, sending a valid port number to this client. Each process communicates with the linked client, as long as it does not send a quit command (or a timeout is not triggered, introduced to avoid leakage issues).
Additional considerations:
- all exceptions linked to server and clients crashes are handled, always ensuring a coherent and stable state when the program execution is resumed;
- the client is able to insert other commands (UP/DOWN/QUIT) even during transfer operations; requests are queued and sequentially handled, according to their order;
- concurrency management among clients accessing to shared resources.
Don’t hesitate to contact me for further information.