Skip to content

UDP Connection to transmit generic class object

Notifications You must be signed in to change notification settings

antodld/UDPDataLink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

UDPDataLink

UDPDataLink is a repository that enables communication of generic class objects using the UDP protocol.

Dependencies

This repository relies on the Boost library.

Installation

  1. Create a 'build' directory at the root of the repository.

  2. In the 'build' directory, run the following commands:

    cmake ..
    sudo make install
    

Use

The object class supposed to be sent should be serializable by boost

Publisher

A data publisher of an object of class T can be initialized and used as such :

const char* serverIP = "127.0.0.1";
const int port = 1234
publisher = UDPDataLink::Publisher<T>();
publisher.create(serverIP, port);
//To send data
T data;
publihser.update_data(data);

Receiver

A data receiver of an object of class T can be initialized and used as such :

const int port = 1234
receiver = UDPDataLink::Receiver<T>();
receiver.create(port);
//To Receive the first data in the buffer
T data;
int res = receiver.receive();
// res = 0 : OK ; 

//To convert the received data into the object
receiver.get(data);

CMake export

target_link_libraries(PROJECT PRIVATE UDPDataLink)

About

UDP Connection to transmit generic class object

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published