GithubHelp home page GithubHelp logo

socket-programming-in-c-language's Introduction

Socket-Programming-in-C-Language

QUESTION 1

There are two directories in this question Client and Server containing the respective codes of client.c and server.c.

Error Handlers:

  • IP Address converting handler
  • Socket creating and connection handler
  • File availability handler

Code Snipet:

# To run the server
cd Q1/Server
gcc server.c -o server
./server
# Now the server is listening to the clients(if no errors in starting the server).
# To check the server-client connection
cd Q2/Client
gcc client.c -o client
./client
# Now all the files present on the server and available to us will be displayed 
# We will be asked to choose one among them
# Type the file name and the file will be downloaded

QUESTION-2

2_1: PERSISTANT CONNECTION

In this type of connection, the connection is maintained once it is established and all the files are transfered through this connection only. TCP Protocol is used in this code snipet and multiple files can be transfered as shown below:

Code Snippet:

cd Q2/Server
gcc server_persistant.c -o server_persistant
./server_persistant
# Now the server is listening to the clients(if no errors in starting the server).
# Don't close this terminal for the second part given below but open a new terminal.
# To check the server-client connection
cd Q2/Client
gcc client_persistant.c -o client_persistant
./client_persistant fileName1 fileName2 fileName3 fileName4
# The above file names will be checked if they are present in the "Data" folder of the server and downloaded if they are present

2_2: NON-PERSISTANT CONNECTION

In this type of connection, every time a new file is requested or is sent from the server side, a new connection over the socket is opened. Here also the code uses the TCP Protocol.

Code Snippet:

cd Q2/Server
gcc server_persistant.c -o server_persistant
./server_persistant
# Now the server is listening to the clients(if no errors in starting the server).
# Don't close this terminal for the second part given below but open a new terminal.
# To check the server-client connection
cd Q2/Client
gcc client_nonpersistant.c -o client_nonpersistant
./client_nonpersistant fileName1 fileName2 fileName3 fileName4
# The above file names will be checked if they are present in the "Data" folder of the server and downloaded if they are present
  • The Persistant connection proved to be faster than Non-Persistant connection when more than 100 files where transfered all together.

socket-programming-in-c-language's People

Contributors

anishgg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.