sachinites / ftp-clientserver Goto Github PK
View Code? Open in Web Editor NEWThis project forked from gudipati/ftp-clientserver
Implemented a File Transfer Protocol (FTP) client-server application (RFC 959) using C Stream Sockets Library in C++
This project forked from gudipati/ftp-clientserver
Implemented a File Transfer Protocol (FTP) client-server application (RFC 959) using C Stream Sockets Library in C++
================================================================ README file for Assignment 3 - FTP Protocol Names and roll numbers: Gowthami Gudipati(11012312) and Tanya Goyal(11012340) Department: Mathematics & Computing ================================================================ HOW TO USE THE FTP PROTOCOL =========================== 1. Copy all the files in one directory. 2. On the terminal: ~$ cd <path-to-main-directory> ~$ make At server side: ~$ cd <path-to-server-directory> ~$ ./server <port number> --> The server should start listening for connections on the specified port. At client side: ~$ cd <path-to-client-directory> ~$ ./client <IP address of server> <port number> 3. Use the following commands: ftp>put <filename> (to upload a file named filename to the server) ftp>get <filename> (to download a file named filename from the server) ftp>ls (to list the files under the present directory of the server) ftp>cd <directory> (to change the present working directory of the server) ftp>pwd (to display the present working directory of the server) ftp>!ls (to list the files under the present directory of the client) ftp>!cd <directory> (to change the present directory of the client) ftp>!pwd (to display the present working directory of the client) ftp>quit (to quit from ftp session at the client and return to Unix prompt) EXIT ==== * You can exit the server by simply using Ctrl + C on the server terminal. * You can close the client by typing "quit" on the client terminal. LIMITATIONS =========== * Only the above mentioned commands are implemented. * A maximum of 8 clients can connect to the server at one time. * There should be no spaces in the directory name to which you want to change the working directory to (because cd <directory> is implemented using chdir(<directory>) which does not allow white spaces) * The get command rewrites the file if it already exists in the client working directory. Similarly, the put command rewrites the file if it already exists in the server working directory. FEATURES ======== * Accepts any of the above mentioned commands. Otherwise, responds back with a "An invalid FTP command" error. * Parses the command and prints the appropriate output on the terminal. * End of file in case of get and put commands is implemented by telling the appropriate process(server/client) the size(or number of blocks) of the file. * Works in connection-oriented and concurrent-server mode. IMPLEMENTATION DETAILS ======================= 1. server.cpp is the file that implements the server side of the FTP protocol as follows: * Creates a Socket and binds it to a port(specified as cmd-line argument) * Starts listening on the socket. * Accepts connections from the client. * Receives FTP command from the client. * Parses the FTP command and checks for errors & unsupported commands. If Error in request, sends the error to client. * All commands are shell commands. They are converted to valid format and executed (by the client/ server as requested). * In case of get command, checks for the appropriate file and sends it to the client over a data connection(data port is generated by the server) in blocks. * In case of put command, receives the file over a data connection(data port is generated by the server) in blocks from the client. * In case of ls command, we use popen("ls","r") and send the list of files over a data connection(data port is generated by the server) in blocks (because the list of files can be huge). * In case of cd <directory> command, we use chdir(<directory>) to change the working directory of the server. * In case of pwd command, we use _getcwd if it is a Windows machine or getcwd otherwise to get the path to current working directory of server and send it to the client. * Closes the connection with client if it receives a "quit" command from the client. * Waits for new connections and repeats the above process. 2. client.cpp is the file that implements the client side of the FTP protocol as follows: * Creates a Socket and connects to the server via the IP address of the server and port(specified as cmd-line arguments) * Parses the FTP command and checks for errors & unsupported commands. If Error in request, prints the error. * All commands are shell commands. They are converted to valid format and executed (by the client/ server as requested). * In case of get command, receives the file over a data connection(data port is generated by the server) in blocks from the server. * In case of put command, checks for the appropriate file and sends it to the server over a data connection(data port is generated by the server) in blocks. * In case of ls command, we receive the list of files over a data connection(again, data port is generated by the server) in blocks (because the list of files can be huge). * In case of !ls command, we use system("ls") to print the list of files under the client working directory. * In case of !cd <directory> command, we use chdir(<directory>) to change the working directory of the client. * In case of !pwd command, we use _getcwd if it is a Windows machine or getcwd otherwise to get the path to current working directory of client. * Returns to Unix prompt at the client if it receives a "quit" command. SAMPLE TEST ============ 1) Initializing the connection: Server Side: Client Side: ~$./server 2000 Server running...waiting for connections. ~$./client 127.0.0.1 2000 Received request... ftp> Child created for dealing with client requests 2) ls Client Side: Server Side: ftp>ls String received from client: ls sample server server.cpp server.o 3) !ls Client Side: Server Side: ftp>!ls String received from client: !ls client client.cpp client.o temp 4) put Client Side: Server Side: ftp>put temp String received from client: put temp File upload done. Filename given is: temp File download done. 5) get Client Side: Server Side: ftp>get sample String received from client: get sample File download done. Filename given is: sample File upload done. 6) pwd Client Side: Server Side: ftp>pwd String received from client: pwd /home/goyal/ftp/Server 7) !pwd Client Side: Server Side: ftp>!pwd String received from client: !pwd /home/goyal/ftp/Client 6) cd Client Side: Server Side: ftp>cd ../Client String received from client: cd ../Client Path given is: ../Client Path given is: ../Client 7) !cd Client Side: Server Side: ftp>!cd ../Server String received from client: !cd ../Server Path given is: ../Server Path given is: ../Server 8) quit Client Side: Server Side: ftp>quit String received from client: quit The client has quit
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.