GithubHelp home page GithubHelp logo

aviad59 / client-server Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 47 KB

Two socket based TCP implementations one using multithreading and second using overlapped i/o.

C 100.00%
thread socket-connection overlapped-io

client-server's Introduction

Client-Server

Welcome! I made this project all by myself as a challenge to make a socket connection in a low language like C instead of just do it the simple way in python.
This project include two small projects and a one ongoing.

All small projects are sharing some few common aspects, the code create a TCP socket connection using the header called "windows.h" and use it to handle a comunication with more than one client. Though each small project does it in a diffrent way!

Server 1.0

The first project is under "Server" folder. Its bassicly an echo server with a little twist which also use multithreding to handle each client, here is a simple yet all-covering exmple.

Exmple:

So lets say two clients: client A and client B are connecting to the server each at its own time, sending some messages and disconnect.

*Client A establishs a connection*
Client A to Server: "Hello"
Server to Client A: "Hello"
Client A t Client A: "World"
Server to Client A: "World"
*Client B establishs a connection*
Server to Client B: "World"
Client B to Server: "Wow"
Server to Client B: "Wow"
Server to Client A: "Wow"
Client A to Server: "That is so cool!"
Server to Client A: "That is so cool!"
Server to Client B: "That is so cool!"

Lets explain what is happening in the above exmple. First the Server make a new thread to handle the Client A connection, then it wait and listen for an input using that thread. When an input comes the thread activate a LOCK mechanism until it finish to save the input in memorie. After that the loop on the thread detect a change in the memorie and output the saved info. Then the last procces can be repeated several times:

server listen -> gets an input -> overwrite the memorie -> detect a new memorie -> output the overwrited memorie -> back to listen

When Client B connects a new thread created for him. First the thread check if there is new data in memorie (if its diffrent than NULL) and output if true. Than that same routines occurs. Due now the LOCK can be active and if so the input will not be saved and accepted by the server, also since all thread check for new data in the memorie the input for the server will be echo for all Clients!.

Server 2.0

//Yet to be documented//

Server 2.0

//Yet to be documented//

client-server's People

Contributors

aviad59 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.