In this assignment you need to implement file transfer protocol on top of TCP sockets. There will be a server and multiple clients communicating with the server. Each client process will open a new connection with the server. Use select to handle multiple client requests.
FTP Commands and there functionality
- RETR : This command causes the remote host to initiate a data connection and to send the requested file over the data connection.
- STOR : This command causes to store a file into the current directory of the remote host.
- LIST : Sends a request to display the list of all files present in the directory.
- ABOR : This command tells the server to abort the previous FTP service command and any associated transfer of data.
- QUIT : This command terminates a USER and if file transfer is not in progress , the server closes the control connection.
- DELE : This command deletes a file in the current directory of server.
Problem
Write two separate C programs one for TCP server (handles requests from multiple servers) and one for client.
Your server program will use the SELECT system call to handle multiple clients. Multiple clients should be simultaneously able to communicate with the server.
You need to implement file transfer protocol between server and client. You should assume the files data structure to be FILE STRUCTURE (i.e. file as a contiguous stream of bytes without internal structure). You may have a single process to handle both control and data communication, at server and client.
Working of server and client is as follows:
- Server accepts connections from clients.
- Server receives control information like FTP commands over this connection.
- Server checks for valid commands, and executes them if there is no error.
- Server creates a new data connection with the client for sending data information.
Only one file can be sent over one data connection.
- The same control connection remains active throughout the user session.
- Client receives the response and displays it to the user.
Implement the following ftp commands:
- RETR <filename>
- STOR <filename>
- LIST
- ABOR
- QUIT
- DELE <filename>
Sample Scenario
Server | Client 1 | Client 2 |
./server 500 | ||
Server running | ||
./client 127.0.0.1 500 | ||
Connected to client 1 | Connected to server | |
LIST | ||
LIST command received from client 1 | ||
Sending list of files to client 1 | A.txt B.txt | |
./client 127.0.0.1 500 | ||
Connected to client 2 | Connected to server | |
RETR A.txt | ||
RETR command received from client 2 | ||
Sending file A.txt to client 2 | ||
Received file A.txt | ||
QUIT | ||
QUIT command received from client 1 | ||
Client 1 disconnected | Disconnected from server | |
QUIT | ||
QUIT command received from client 2 | ||
Client 2 disconnected | Disconnected from | |
server |
Reviews
There are no reviews yet.