PROJECT TITLE :
FTP based Client Server project using sockets and threads:
Abstract:
File Transfer Protocol is a standard network protocol used to transfer files from one host to another host over a TCP based network such as internet. This protocol can be used to upload or download files form one host to another. This protocol is based on cilent-server architecture and may use different control and data connections between the client and the server.
I tried to implement FTP to transfer files within and over the network(using internet) using C language.
Architecture:
There may be a server running and waiting for clients to log in(initiate communication). Once any client approaches the server to upload a file, it waits in a queue untill server accepts its request. The server may ask the client to login before further processing its request. Also the server may ask few times for correct password and failing to get that server may refuse to connect to that client.
Implementation:
SERVER-SIDE:
1. I implemented server and used socket() system call to make a socket on the server side.
This call makes a socket in the namespace(address family) but it has no address is assigned to it.
And it also provides mechanisms to communicate with network layer.
2. Then i named that socket using bind() system call.
This system call assignes the address specified by one of its arguments to the socket referred to by
file_descriptor returned by socket().
3. Then i used listen() system call, which implements a listening queue to take requests from various clients to be processed by the server.
4. Finally i used accept() system call to take requests from listening queue and implemented authentication functionality to provide access to the clients.
5. If clients enters correct credentials if may proceed to upload a file.
6. After getting the file server may proceed to handle another request from listening queue.
NOTE: I used accept() in a ‘forever’ loop so that server may be running all the time.
Once the client is successfully logged-in i implemented POSIX threads to take the any number of files(tested for 1000 files) fron that specific client.
CLIENT-SIDE:
1. I implemented client and used socket() system call to make a socket on the client side.
2. Then, i used connect() system call to send request to the server.
3. Now when server is ready to accept the request then client is promped to enter its details along with passwords.
4. Once the authentication is successfully done then client may send any number of files to the server in one go.
5. After successfully sending file client may terminate or re-request the server to send more files.
The above algorithm was implemented and tested using AF_INET (address family) to transfer file within a private network.
File can also be sent over the internet using the above algorithm but for that we may need to acquire the public ip address assigned to us.
Another method is to use a technique referred to as “PORT FORWARDING“.
This technique is only to be used at server’s side and it requires us to configure our router so that it may direct the incomming packets for a particular port address on server’s ip address.
Future scope:
If we are not allowed to change router’s configuration then we can establish a VPN, which is used to directly communicate with a particular machine without even going through the router associated with that machine.
Thank You
HARPREET SINGH
ece.harpreetsingh@gmail.com