Code Monkey home page Code Monkey logo

asynchronous-socket-class-c-windows's Introduction

Why

Native socket implementation in C++ is... how to say... A TOTAL BRAINF***. If you never tryed to use them, don't try now! SocketClient allows easy communication between sockets and implements a callback pattern for receiving messages!

Callback Pattern

The SocketClient class implements a callback pattern which is very usefull to handle messages and catch errors easily.

For those who don't know: A callback is a function called when a specific event happen in the system. In this case, the callback will be called for every incoming message through the socket. You don't have to care about receiving messages, you are automatically alerted when you receive something.

Sample

I made a simple Server/Client connection for the example: The Client connects to the server and can send as many messages as he wants. The Server implements the callback functions and displays the messages.

Server: https://github.com/omaflak/Asynchronous-Socket-Class-C-Windows/blob/master/main_server.cpp

Client: https://github.com/omaflak/Asynchronous-Socket-Class-C-Windows/blob/master/main_client.cpp

Compilation

g++ main_client.cpp -o client.exe libSocket.a "C:\path\to\lib\libws2_32.a"
g++ main_server.cpp -o server.exe libSocket.a "C:\path\to\lib\libws2_32.a"

SocketClient.h and SocketServer.h must be with YOUR .cpp files, i.e in the same folder.

Tutorial

For more explanations about the installation, please visit my website: https://causeyourestuck.io/2016/02/21/socket-library-c/

asynchronous-socket-class-c-windows's People

Contributors

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