UDPDataLink is a repository that enables communication of generic class objects using the UDP protocol.
This repository relies on the Boost library.
-
Create a 'build' directory at the root of the repository.
-
In the 'build' directory, run the following commands:
cmake .. sudo make install
The object class supposed to be sent should be serializable by boost
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);
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);
target_link_libraries(PROJECT PRIVATE UDPDataLink)