OpenDaVINCI  4.16.0
odcore::io::udp::UDPSender Class Referenceabstract

#include <UDPSender.h>

Inheritance diagram for odcore::io::udp::UDPSender:
Inheritance graph

Public Member Functions

virtual ~UDPSender ()
 
virtual void send (const string &data) const =0
 
virtual uint16_t getPort () const =0
 

Detailed Description

This interface encapsulates the necessary methods for sending data using UDP. This interface is implemented by Boost or plain POSIX system calls.

It can be used as follows:

const string address = "192.168.0.22";
const uint32_t port = 12345;
std::shared_ptr<UDPSender> s;
try {
s = UDPFactory::createUDPSender(address, port);
}
catch(string &st) {
clog << "Failed: " << st << endl;
}
if (s.isValid()) {
s->send("ABCD");
}
...

Constructor & Destructor Documentation

odcore::io::udp::UDPSender::~UDPSender ( )
virtual

Member Function Documentation

virtual uint16_t odcore::io::udp::UDPSender::getPort ( ) const
pure virtual

This method returns the port in use when sending UDP packets.

Returns
Port when sending UDP packets.

Implemented in odcore::wrapper::POSIX::POSIXUDPSender, and odcore::wrapper::WIN32Impl::WIN32UDPSender.

virtual void odcore::io::udp::UDPSender::send ( const string &  data) const
pure virtual

This method sends data using UDP.

Parameters
dataData to be sent.

Implemented in odcore::wrapper::POSIX::POSIXUDPSender, and odcore::wrapper::WIN32Impl::WIN32UDPSender.