Thunderbots Project
Loading...
Searching...
No Matches
UdpListener Class Reference

#include <udp_listener.h>

Public Member Functions

 UdpListener (boost::asio::io_service &io_service, const std::string &ip_address, unsigned short port, const std::string &interface, bool multicast, ReceiveCallback receive_callback)
 
 UdpListener (boost::asio::io_service &io_service, const unsigned short port, ReceiveCallback receive_callback)
 
virtual ~UdpListener ()
 
void close ()
 

Detailed Description

Creates a UDP listener that can listen on a given port and interface.

Constructor & Destructor Documentation

◆ UdpListener() [1/2]

UdpListener ( boost::asio::io_service &  io_service,
const std::string &  ip_address,
unsigned short  port,
const std::string &  interface,
bool  multicast,
ReceiveCallback  receive_callback 
)

Creates a UDP listener.

Exceptions
TbotsNetworkExceptionif the listener could not be created
Parameters
io_serviceThe service thread to use for the network communication resource
ip_addressIf multicast is true, this address is the multicast group to join. Otherwise, this is the IP address of the local interface to listen on
portThe port to listen on
interfaceThe networking interface to listen on
multicastIf true, the listener will join the multicast group given by ip_address, otherwise it will listen on the local interface given by ip_address and interface
receive_callbackThe callback to call when a new message is received

◆ UdpListener() [2/2]

UdpListener ( boost::asio::io_service &  io_service,
const unsigned short  port,
ReceiveCallback  receive_callback 
)

Creates a UDP listener that listens on the given port on all interfaces.

A user must check the user-provided error string to see if the listener construction was successful.

Exceptions
TbotsNetworkExceptionif the listener could not be created
Parameters
io_serviceThe service thread to use for the network communication resource
portThe port to listen on
receive_callbackThe callback to call when a new message is received

◆ ~UdpListener()

~UdpListener ( )
virtual

Destructor.

Member Function Documentation

◆ close()

void close ( )

Cleans up all associated networking resources with this listener.


The documentation for this class was generated from the following files: