Giter Site home page Giter Site logo

medazzo / ecomm Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 236 KB

Full Duplex IPC Communication olibrary based on Named pipes or System V Message Queue.

License: MIT License

CMake 14.87% C++ 85.13%
ipc c cpp cplusplus system systemv message-queue fifo queue wrapper

ecomm's Introduction

ecomm

Build Status

Full Duplex IPC Communication olibrary based on Named pipes or System V Message Queue.

This library can work in one direction : one process will read and the others will write or in both : full duplex : both can read and write.

The Library will manipulates strnig and object that can be serialized into string and deserialized from string.

It work by defaults using Named pipes FIFO, and also can use V system Messages Queue.

ecomm concept

On every half duplex communication required , it create a pipe(or a Queue ) and manage sending receiving by proposnig the correct Api . That's managed by class EasinComm. So the class EasinCommFull that support Full Duplex haas two instace of EasinComm. The library doesnt not manage thead , it's no the caller responsaability.

ecomm Object

We call that Object that be sent or reveic in communication between process . It can be any class that fit soe condition :

  • have a cstructor from string , that ca ndeserialize object from that params
  • implement serialize from src/EasinCommObj.h
class EasinCommObj {
public:
    virtual std::string Serialize() = 0 ;
    
};

How ecomm Object is Sent/Received

The serialization operation must be transorm objet params in a string where :

  • fields will be separated by ;
  • once done , the result must be end with END;

Theses two constants, are defined in src/EasinComm.h, and can be changed if needed :

#define END_STRING          "END;"
#define END_STRING_LENGTH   4
#define SEP_STRING          ";"

The deserialization operation shall do the oposite.

An example to follw is here tests/EasinCommand.f

class EasinCommand: public EasinCommObj {
public:
...
    EasinCommand(std::string command)
    {
        std::istringstream f(command);
        std::string s;  
        int i=0;
        while (getline(f, s, ';')) {
            if(i == 0)
                m_id = s;
            else if(i==1)
                m_command = s ;
            else
                m_params.push_back(s);
            i++;
        }
    };

    std::string Serialize(){
        std::string  params="";
        for (int i=0;i<m_params.size();i++)
            params+= m_params[i] + SEP_STRING;
        return std::string(m_id + SEP_STRING + m_command + SEP_STRING + params + END_STRING);
    };

private:
    std::string m_id;
    std::string m_command;
    std::vector<std::string> m_params;
};

ecomm tests

Tests are built by default ( we can disable that using cmake option -DBUILD_TESTS=off ) We generate two binary for half and full duplex :

  • for half duplex : testecomm :
    • run it with params RECEIVER or SENDER
    • This tests will send messages from Sender To Receiver
    • Default message amount on source code 1000000 , that will be sent on about 11m6,424s min using Fifo.
  • for Full Duplex : testfullecomm : run it with params SIDE1 or SIDE2
    • run it with params SIDE1 or SIDE2
    • This tests will send messages from SIDE To SIDE in both direction
    • Default message amount on source code 1000000 , meaning total message exchanged are the double, that will be sent on about 10m55,380s min using Fifo.

ecomm Tests

ecomm's People

Contributors

medazzo avatar

Watchers

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