Skip to content

Programs written in C to demonstrate how UNIX socket work and to create a server-client architecture using UNIX sockets

Notifications You must be signed in to change notification settings

hyp3r5pace/socket-programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

socket-programming

Programs written in C to demonstrate how UNIX socket work and to create a server-client architecture using UNIX sockets.

This repository contains three types of server-client architecture -

1. Server - Client 1

This server client architecture is a trivial one!
The server is a single process server which can maintain at most of one client connection at a time. Any connection request from other clients during a ongoing connection is rejected by the server.

2. Server - client 2

The server is a multiprocess server which spawns a new child process for each new connection request. Thus each connection is handled by different child processes. The server can handle multiple connections at a time.

3. Server - client 3

The server is a single process server which can handle multiple connections at a time upto a certain limit. In this case,the server can handle 256 connections at a time. Further Connections are rejected. The upper limit for the number of connections server can handle, can be changed by tweaking the server code a little bit.

To run the server:

first compile the server

gcc server.c -o server
./server

example:
gcc server1.c -o server1
./server1 5666

To run a client:

first compile the client

gcc client.c -o client
./client

example:
gcc client1.c -o client1
./client1 127.0.0.1 5666

PS: The code may be a little cluttered but I am not going to declutter it since the comments document my findings and thought process while I was researching and creating the client server model. Some of the comments also state some queries which are not addressed yet and some finding and research still needs to be done by me regarding them. All the code comments are precious!

About

Programs written in C to demonstrate how UNIX socket work and to create a server-client architecture using UNIX sockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages