Basic UDP server class based on OS sockets that supports receiving messages.
More...
#include <udp_server.h>
|
| UDPServer (std::string local_address, uint16_t local_port, size_t rx_buffer_size=0) |
|
| UDPServer (std::string local_address, std::string local_port, size_t rx_buffer_size=0) |
|
UDPServer & | operator= (const UDPServer &)=delete |
|
| UDPServer (const UDPServer &)=delete |
|
| ~UDPServer ()=default |
|
ssize_t | Connect (const std::string &remote_address, const std::string &remote_port) |
| The remote_address | remote_port is the only address to which datagrams are received. 1:1 association remote<-me. More...
|
|
ssize_t | Connect (const std::string &remote_address, uint16_t remote_port) |
|
ssize_t | Recv (std::byte *buf, size_t len) const |
| Try to receive up to len bytes in buf by default this will not block. More...
|
|
ssize_t | Recv (const std::string &src_address, uint16_t src_port, std::byte *buf, size_t len) |
|
void | MakeBlocking (size_t timeout_sec=0) const |
| Configures the socket in blocking mode. Any calls to recv / send will now block. More...
|
|
const std::string & | Address () const |
|
const std::string & | Port () const |
|
Basic UDP server class based on OS sockets that supports receiving messages.
◆ UDPServer() [1/3]
UDPServer::UDPServer |
( |
std::string |
local_address, |
|
|
uint16_t |
local_port, |
|
|
size_t |
rx_buffer_size = 0 |
|
) |
| |
|
inlineexplicit |
◆ UDPServer() [2/3]
UDPServer::UDPServer |
( |
std::string |
local_address, |
|
|
std::string |
local_port, |
|
|
size_t |
rx_buffer_size = 0 |
|
) |
| |
|
inlineexplicit |
◆ UDPServer() [3/3]
◆ ~UDPServer()
UDPServer::~UDPServer |
( |
| ) |
|
|
default |
◆ Address()
const std::string& UDPServer::Address |
( |
| ) |
const |
|
inline |
◆ Connect() [1/2]
ssize_t UDPServer::Connect |
( |
const std::string & |
remote_address, |
|
|
const std::string & |
remote_port |
|
) |
| |
|
inline |
The remote_address | remote_port is the only address to which datagrams are received. 1:1 association remote<-me.
- Parameters
-
remote_address | Hostname or IP address of the remote server |
remote_port | UDP port of the remote server |
◆ Connect() [2/2]
ssize_t UDPServer::Connect |
( |
const std::string & |
remote_address, |
|
|
uint16_t |
remote_port |
|
) |
| |
|
inline |
◆ MakeBlocking()
void UDPServer::MakeBlocking |
( |
size_t |
timeout_sec = 0 | ) |
const |
|
inline |
Configures the socket in blocking mode. Any calls to recv / send will now block.
◆ operator=()
◆ Port()
const std::string& UDPServer::Port |
( |
| ) |
const |
|
inline |
◆ Recv() [1/2]
ssize_t UDPServer::Recv |
( |
const std::string & |
src_address, |
|
|
uint16_t |
src_port, |
|
|
std::byte * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
inline |
◆ Recv() [2/2]
ssize_t UDPServer::Recv |
( |
std::byte * |
buf, |
|
|
size_t |
len |
|
) |
| const |
|
inline |
Try to receive up to len bytes in buf by default this will not block.
- Returns
- Return the number of bytes received if non-zero bytes are received. If no bytes are received, return zero. If there was an error in receiving, return -1.
◆ address_
const std::string UDPServer::address_ |
|
private |
The UDP port to server is listening on.
◆ comm_object_
◆ port_
const std::string UDPServer::port_ |
|
private |
The documentation for this class was generated from the following file: