This work deals with basic socket programming context. This root directory
contains two main directory one for SERVER node and other for CLIENT node.
Overall working is:
- The client will create/request a connection to the server
- After successfull connection client can send either
get <filenames>orexitREQUEST get <filenames>will download files to directoryCLIENT/downloadsfromSERVER/downloadable_filesdirectoryexitwill close the connection- Progress will be printed while downloading the file on both server and client terminals.
- Connection is basically made of type
TCP/IPV4 - Error handling such as requesting missing files has been handled appropriately.
Follow the steps to run the code:
-
Open 2 terminal windows
-
Open
SERVERdirectory in one andCLIENTin other. -
In
SERVERdirectory run the following commands:gcc server.c -o serverthenclear;./serverYou will get output on terminal:server setup complete: waiting for connections... -
In
CLIENTdirectory run the following commands:gcc client.c -o clientthenclear;./clientYou will get a red color prompt. -
Before running any command place some dummy files of your choice in directory
SERVER/downloadable_files. I have already put a dummy file. Check it out. -
Your Client is now connected to the Server and go download the available files...
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #include<sys/socket.h>
- #include<sys/stat.h>
- #include<netinet/in.h>
- #include<unistd.h>
- #include<arpa/inet.h> // only in client.c
- #include<fcntl.h>