CppServer  1.0.4.0
C++ Server Library
Public Member Functions | Protected Member Functions | List of all members
CppServer::Asio::UDPClient Class Reference

UDP client. More...

#include <udp_client.h>

Inheritance diagram for CppServer::Asio::UDPClient:

Public Member Functions

 UDPClient (const std::shared_ptr< Service > &service, const std::string &address, int port)
 Initialize UDP client with a given Asio service, server address and port number. More...
 
 UDPClient (const std::shared_ptr< Service > &service, const std::string &address, const std::string &scheme)
 Initialize UDP client with a given Asio service, server address and scheme name. More...
 
 UDPClient (const std::shared_ptr< Service > &service, const asio::ip::udp::endpoint &endpoint)
 Initialize UDP client with a given Asio service and endpoint. More...
 
 UDPClient (const UDPClient &)=delete
 
 UDPClient (UDPClient &&)=delete
 
virtual ~UDPClient ()=default
 
UDPClientoperator= (const UDPClient &)=delete
 
UDPClientoperator= (UDPClient &&)=delete
 
const CppCommon::UUID & id () const noexcept
 Get the client Id. More...
 
std::shared_ptr< Service > & service () noexcept
 Get the Asio service. More...
 
std::shared_ptr< asio::io_service > & io_service () noexcept
 Get the Asio IO service. More...
 
asio::io_service::strand & strand () noexcept
 Get the Asio service strand for serialized handler execution. More...
 
asio::ip::udp::endpoint & endpoint () noexcept
 Get the client endpoint. More...
 
asio::ip::udp::socket & socket () noexcept
 Get the client socket. More...
 
const std::string & address () const noexcept
 Get the server address. More...
 
const std::string & scheme () const noexcept
 Get the scheme name. More...
 
int port () const noexcept
 Get the server port number. More...
 
uint64_t bytes_pending () const noexcept
 Get the number of bytes pending sent by the client. More...
 
uint64_t bytes_sent () const noexcept
 Get the number of bytes sent by the client. More...
 
uint64_t bytes_received () const noexcept
 Get the number of bytes received by the client. More...
 
uint64_t datagrams_sent () const noexcept
 Get the number datagrams sent by the client. More...
 
uint64_t datagrams_received () const noexcept
 Get the number datagrams received by the client. More...
 
bool option_reuse_address () const noexcept
 Get the option: reuse address. More...
 
bool option_reuse_port () const noexcept
 Get the option: reuse port. More...
 
bool option_multicast () const noexcept
 Get the option: bind the socket to the multicast UDP server. More...
 
size_t option_receive_buffer_limit () const noexcept
 Get the option: receive buffer limit. More...
 
size_t option_receive_buffer_size () const
 Get the option: receive buffer size. More...
 
size_t option_send_buffer_limit () const noexcept
 Get the option: send buffer limit. More...
 
size_t option_send_buffer_size () const
 Get the option: send buffer size. More...
 
bool IsConnected () const noexcept
 Is the client connected? More...
 
virtual bool Connect ()
 Connect the client (synchronous) More...
 
virtual bool Connect (const std::shared_ptr< UDPResolver > &resolver)
 Connect the client using the given DNS resolver (synchronous) More...
 
virtual bool Disconnect ()
 Disconnect the client (synchronous) More...
 
virtual bool Reconnect ()
 Reconnect the client (synchronous) More...
 
virtual bool ConnectAsync ()
 Connect the client (asynchronous) More...
 
virtual bool ConnectAsync (const std::shared_ptr< UDPResolver > &resolver)
 Connect the client using the given DNS resolver (asynchronous) More...
 
virtual bool DisconnectAsync ()
 Disconnect the client (asynchronous) More...
 
virtual bool ReconnectAsync ()
 Reconnect the client (asynchronous) More...
 
virtual void JoinMulticastGroup (const std::string &address)
 Join multicast group with a given address (synchronous) More...
 
virtual void LeaveMulticastGroup (const std::string &address)
 Leave multicast group with a given address (synchronous) More...
 
virtual void JoinMulticastGroupAsync (const std::string &address)
 Join multicast group with a given address (asynchronous) More...
 
virtual void LeaveMulticastGroupAsync (const std::string &address)
 Leave multicast group with a given address (asynchronous) More...
 
virtual size_t Send (const void *buffer, size_t size)
 Send datagram to the connected server (synchronous) More...
 
virtual size_t Send (std::string_view text)
 Send text to the connected server (synchronous) More...
 
virtual size_t Send (const asio::ip::udp::endpoint &endpoint, const void *buffer, size_t size)
 Send datagram to the given endpoint (synchronous) More...
 
virtual size_t Send (const asio::ip::udp::endpoint &endpoint, std::string_view text)
 Send text to the given endpoint (synchronous) More...
 
virtual size_t Send (const void *buffer, size_t size, const CppCommon::Timespan &timeout)
 Send datagram to the connected server with timeout (synchronous) More...
 
virtual size_t Send (std::string_view text, const CppCommon::Timespan &timeout)
 Send text to the connected server with timeout (synchronous) More...
 
virtual size_t Send (const asio::ip::udp::endpoint &endpoint, const void *buffer, size_t size, const CppCommon::Timespan &timeout)
 Send datagram to the given endpoint with timeout (synchronous) More...
 
virtual size_t Send (const asio::ip::udp::endpoint &endpoint, std::string_view text, const CppCommon::Timespan &timeout)
 Send text to the given endpoint with timeout (synchronous) More...
 
virtual bool SendAsync (const void *buffer, size_t size)
 Send datagram to the connected server (asynchronous) More...
 
virtual bool SendAsync (std::string_view text)
 Send text to the connected server (asynchronous) More...
 
virtual bool SendAsync (const asio::ip::udp::endpoint &endpoint, const void *buffer, size_t size)
 Send datagram to the given endpoint (asynchronous) More...
 
virtual bool SendAsync (const asio::ip::udp::endpoint &endpoint, std::string_view text)
 Send text to the given endpoint (asynchronous) More...
 
virtual size_t Receive (asio::ip::udp::endpoint &endpoint, void *buffer, size_t size)
 Receive datagram from the given endpoint (synchronous) More...
 
virtual std::string Receive (asio::ip::udp::endpoint &endpoint, size_t size)
 Receive text from the given endpoint (synchronous) More...
 
virtual size_t Receive (asio::ip::udp::endpoint &endpoint, void *buffer, size_t size, const CppCommon::Timespan &timeout)
 Receive datagram from the given endpoint with timeout (synchronous) More...
 
virtual std::string Receive (asio::ip::udp::endpoint &endpoint, size_t size, const CppCommon::Timespan &timeout)
 Receive text from the given endpoint with timeout (synchronous) More...
 
virtual void ReceiveAsync ()
 Receive datagram from the server (asynchronous) More...
 
void SetupReuseAddress (bool enable) noexcept
 Setup option: reuse address. More...
 
void SetupReusePort (bool enable) noexcept
 Setup option: reuse port. More...
 
void SetupMulticast (bool enable) noexcept
 Setup option: bind the socket to the multicast UDP server. More...
 
void SetupReceiveBufferLimit (size_t limit) noexcept
 Setup option: receive buffer limit. More...
 
void SetupReceiveBufferSize (size_t size)
 Setup option: receive buffer size. More...
 
void SetupSendBufferLimit (size_t limit) noexcept
 Setup option: send buffer limit. More...
 
void SetupSendBufferSize (size_t size)
 Setup option: send buffer size. More...
 

Protected Member Functions

virtual void onConnected ()
 Handle client connected notification. More...
 
virtual void onDisconnected ()
 Handle client disconnected notification. More...
 
virtual void onJoinedMulticastGroup (const std::string &address)
 Handle client joined multicast group notification. More...
 
virtual void onLeftMulticastGroup (const std::string &address)
 Handle client left multicast group notification. More...
 
virtual void onReceived (const asio::ip::udp::endpoint &endpoint, const void *buffer, size_t size)
 Handle datagram received notification. More...
 
virtual void onSent (const asio::ip::udp::endpoint &endpoint, size_t sent)
 Handle datagram sent notification. More...
 
virtual void onError (int error, const std::string &category, const std::string &message)
 Handle error notification. More...
 

Detailed Description

UDP client.

UDP client is used to read/write datagrams from/into the connected UDP server.

Thread-safe.

Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 29 of file udp_client.h.

Constructor & Destructor Documentation

◆ UDPClient() [1/5]

CppServer::Asio::UDPClient::UDPClient ( const std::shared_ptr< Service > &  service,
const std::string &  address,
int  port 
)

Initialize UDP client with a given Asio service, server address and port number.

Parameters
service- Asio service
address- Server address
port- Server port number
Examples
udp_echo_client.cpp.

Definition at line 14 of file udp_client.cpp.

◆ UDPClient() [2/5]

CppServer::Asio::UDPClient::UDPClient ( const std::shared_ptr< Service > &  service,
const std::string &  address,
const std::string &  scheme 
)

Initialize UDP client with a given Asio service, server address and scheme name.

Parameters
service- Asio service
address- Server address
scheme- Scheme name

Definition at line 41 of file udp_client.cpp.

◆ UDPClient() [3/5]

CppServer::Asio::UDPClient::UDPClient ( const std::shared_ptr< Service > &  service,
const asio::ip::udp::endpoint &  endpoint 
)

Initialize UDP client with a given Asio service and endpoint.

Parameters
service- Asio service
endpoint- Server UDP endpoint

Definition at line 69 of file udp_client.cpp.

◆ UDPClient() [4/5]

CppServer::Asio::UDPClient::UDPClient ( const UDPClient )
delete

◆ UDPClient() [5/5]

CppServer::Asio::UDPClient::UDPClient ( UDPClient &&  )
delete

◆ ~UDPClient()

virtual CppServer::Asio::UDPClient::~UDPClient ( )
virtualdefault

Member Function Documentation

◆ address()

const std::string& CppServer::Asio::UDPClient::address ( ) const
inlinenoexcept

Get the server address.

Definition at line 74 of file udp_client.h.

◆ bytes_pending()

uint64_t CppServer::Asio::UDPClient::bytes_pending ( ) const
inlinenoexcept

Get the number of bytes pending sent by the client.

Definition at line 81 of file udp_client.h.

◆ bytes_received()

uint64_t CppServer::Asio::UDPClient::bytes_received ( ) const
inlinenoexcept

Get the number of bytes received by the client.

Definition at line 85 of file udp_client.h.

◆ bytes_sent()

uint64_t CppServer::Asio::UDPClient::bytes_sent ( ) const
inlinenoexcept

Get the number of bytes sent by the client.

Definition at line 83 of file udp_client.h.

◆ Connect() [1/2]

bool CppServer::Asio::UDPClient::Connect ( )
virtual

Connect the client (synchronous)

Returns
'true' if the client was successfully connected, 'false' if the client failed to connect

Definition at line 123 of file udp_client.cpp.

◆ Connect() [2/2]

bool CppServer::Asio::UDPClient::Connect ( const std::shared_ptr< UDPResolver > &  resolver)
virtual

Connect the client using the given DNS resolver (synchronous)

Parameters
resolver- DNS resolver
Returns
'true' if the client was successfully connected, 'false' if the client failed to connect

Definition at line 173 of file udp_client.cpp.

◆ ConnectAsync() [1/2]

bool CppServer::Asio::UDPClient::ConnectAsync ( )
virtual

Connect the client (asynchronous)

Returns
'true' if the client was successfully connected, 'false' if the client failed to connect
Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 275 of file udp_client.cpp.

◆ ConnectAsync() [2/2]

bool CppServer::Asio::UDPClient::ConnectAsync ( const std::shared_ptr< UDPResolver > &  resolver)
virtual

Connect the client using the given DNS resolver (asynchronous)

Parameters
resolver- DNS resolver
Returns
'true' if the client was successfully connected, 'false' if the client failed to connect

Definition at line 291 of file udp_client.cpp.

◆ datagrams_received()

uint64_t CppServer::Asio::UDPClient::datagrams_received ( ) const
inlinenoexcept

Get the number datagrams received by the client.

Definition at line 89 of file udp_client.h.

◆ datagrams_sent()

uint64_t CppServer::Asio::UDPClient::datagrams_sent ( ) const
inlinenoexcept

Get the number datagrams sent by the client.

Definition at line 87 of file udp_client.h.

◆ Disconnect()

virtual bool CppServer::Asio::UDPClient::Disconnect ( )
inlinevirtual

Disconnect the client (synchronous)

Returns
'true' if the client was successfully disconnected, 'false' if the client is already disconnected

Definition at line 124 of file udp_client.h.

◆ DisconnectAsync()

virtual bool CppServer::Asio::UDPClient::DisconnectAsync ( )
inlinevirtual

Disconnect the client (asynchronous)

Returns
'true' if the client was successfully disconnected, 'false' if the client is already disconnected
Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 146 of file udp_client.h.

◆ endpoint()

asio::ip::udp::endpoint& CppServer::Asio::UDPClient::endpoint ( )
inlinenoexcept

Get the client endpoint.

Definition at line 69 of file udp_client.h.

◆ id()

const CppCommon::UUID& CppServer::Asio::UDPClient::id ( ) const
inlinenoexcept

Get the client Id.

Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 60 of file udp_client.h.

◆ io_service()

std::shared_ptr<asio::io_service>& CppServer::Asio::UDPClient::io_service ( )
inlinenoexcept

Get the Asio IO service.

Definition at line 65 of file udp_client.h.

◆ IsConnected()

bool CppServer::Asio::UDPClient::IsConnected ( ) const
inlinenoexcept

Is the client connected?

Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 107 of file udp_client.h.

◆ JoinMulticastGroup()

void CppServer::Asio::UDPClient::JoinMulticastGroup ( const std::string &  address)
virtual

Join multicast group with a given address (synchronous)

Parameters
address- Multicast group address
Examples
udp_multicast_client.cpp.

Definition at line 419 of file udp_client.cpp.

◆ JoinMulticastGroupAsync()

void CppServer::Asio::UDPClient::JoinMulticastGroupAsync ( const std::string &  address)
virtual

Join multicast group with a given address (asynchronous)

Parameters
address- Multicast group address

Definition at line 447 of file udp_client.cpp.

◆ LeaveMulticastGroup()

void CppServer::Asio::UDPClient::LeaveMulticastGroup ( const std::string &  address)
virtual

Leave multicast group with a given address (synchronous)

Parameters
address- Multicast group address

Definition at line 433 of file udp_client.cpp.

◆ LeaveMulticastGroupAsync()

void CppServer::Asio::UDPClient::LeaveMulticastGroupAsync ( const std::string &  address)
virtual

Leave multicast group with a given address (asynchronous)

Parameters
address- Multicast group address

Definition at line 461 of file udp_client.cpp.

◆ onConnected()

virtual void CppServer::Asio::UDPClient::onConnected ( )
inlineprotectedvirtual

Handle client connected notification.

Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 355 of file udp_client.h.

◆ onDisconnected()

virtual void CppServer::Asio::UDPClient::onDisconnected ( )
inlineprotectedvirtual

Handle client disconnected notification.

Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 357 of file udp_client.h.

◆ onError()

virtual void CppServer::Asio::UDPClient::onError ( int  error,
const std::string &  category,
const std::string &  message 
)
inlineprotectedvirtual

Handle error notification.

Parameters
error- Error code
category- Error category
message- Error message
Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 398 of file udp_client.h.

◆ onJoinedMulticastGroup()

virtual void CppServer::Asio::UDPClient::onJoinedMulticastGroup ( const std::string &  address)
inlineprotectedvirtual

Handle client joined multicast group notification.

Parameters
address- Multicast group address

Definition at line 363 of file udp_client.h.

◆ onLeftMulticastGroup()

virtual void CppServer::Asio::UDPClient::onLeftMulticastGroup ( const std::string &  address)
inlineprotectedvirtual

Handle client left multicast group notification.

Parameters
address- Multicast group address

Definition at line 368 of file udp_client.h.

◆ onReceived()

virtual void CppServer::Asio::UDPClient::onReceived ( const asio::ip::udp::endpoint &  endpoint,
const void *  buffer,
size_t  size 
)
inlineprotectedvirtual

Handle datagram received notification.

Notification is called when another datagram was received from some endpoint.

Parameters
endpoint- Received endpoint
buffer- Received datagram buffer
size- Received datagram buffer size
Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 379 of file udp_client.h.

◆ onSent()

virtual void CppServer::Asio::UDPClient::onSent ( const asio::ip::udp::endpoint &  endpoint,
size_t  sent 
)
inlineprotectedvirtual

Handle datagram sent notification.

Notification is called when a datagram was sent to the server.

This handler could be used to send another datagram to the server for instance when the pending size is zero.

Parameters
endpoint- Endpoint of sent datagram
sent- Size of sent datagram buffer

Definition at line 390 of file udp_client.h.

◆ operator=() [1/2]

UDPClient& CppServer::Asio::UDPClient::operator= ( const UDPClient )
delete

◆ operator=() [2/2]

UDPClient& CppServer::Asio::UDPClient::operator= ( UDPClient &&  )
delete

◆ option_multicast()

bool CppServer::Asio::UDPClient::option_multicast ( ) const
inlinenoexcept

Get the option: bind the socket to the multicast UDP server.

Definition at line 96 of file udp_client.h.

◆ option_receive_buffer_limit()

size_t CppServer::Asio::UDPClient::option_receive_buffer_limit ( ) const
inlinenoexcept

Get the option: receive buffer limit.

Definition at line 98 of file udp_client.h.

◆ option_receive_buffer_size()

size_t CppServer::Asio::UDPClient::option_receive_buffer_size ( ) const

Get the option: receive buffer size.

Definition at line 97 of file udp_client.cpp.

◆ option_reuse_address()

bool CppServer::Asio::UDPClient::option_reuse_address ( ) const
inlinenoexcept

Get the option: reuse address.

Definition at line 92 of file udp_client.h.

◆ option_reuse_port()

bool CppServer::Asio::UDPClient::option_reuse_port ( ) const
inlinenoexcept

Get the option: reuse port.

Definition at line 94 of file udp_client.h.

◆ option_send_buffer_limit()

size_t CppServer::Asio::UDPClient::option_send_buffer_limit ( ) const
inlinenoexcept

Get the option: send buffer limit.

Definition at line 102 of file udp_client.h.

◆ option_send_buffer_size()

size_t CppServer::Asio::UDPClient::option_send_buffer_size ( ) const

Get the option: send buffer size.

Definition at line 104 of file udp_client.cpp.

◆ port()

int CppServer::Asio::UDPClient::port ( ) const
inlinenoexcept

Get the server port number.

Definition at line 78 of file udp_client.h.

◆ Receive() [1/4]

std::string CppServer::Asio::UDPClient::Receive ( asio::ip::udp::endpoint &  endpoint,
size_t  size 
)
virtual

Receive text from the given endpoint (synchronous)

Parameters
endpoint- Endpoint to receive from
size- Text size to receive
Returns
Received text

Definition at line 699 of file udp_client.cpp.

◆ Receive() [2/4]

std::string CppServer::Asio::UDPClient::Receive ( asio::ip::udp::endpoint &  endpoint,
size_t  size,
const CppCommon::Timespan &  timeout 
)
virtual

Receive text from the given endpoint with timeout (synchronous)

Parameters
endpoint- Endpoint to receive from
size- Text size to receive
timeout- Timeout
Returns
Received text

Definition at line 766 of file udp_client.cpp.

◆ Receive() [3/4]

size_t CppServer::Asio::UDPClient::Receive ( asio::ip::udp::endpoint &  endpoint,
void *  buffer,
size_t  size 
)
virtual

Receive datagram from the given endpoint (synchronous)

Parameters
endpoint- Endpoint to receive from
buffer- Datagram buffer to receive
size- Datagram buffer size to receive
Returns
Size of received datagram

Definition at line 665 of file udp_client.cpp.

◆ Receive() [4/4]

size_t CppServer::Asio::UDPClient::Receive ( asio::ip::udp::endpoint &  endpoint,
void *  buffer,
size_t  size,
const CppCommon::Timespan &  timeout 
)
virtual

Receive datagram from the given endpoint with timeout (synchronous)

Parameters
endpoint- Endpoint to receive from
buffer- Datagram buffer to receive
size- Datagram buffer size to receive
timeout- Timeout
Returns
Size of received datagram

Definition at line 706 of file udp_client.cpp.

◆ ReceiveAsync()

void CppServer::Asio::UDPClient::ReceiveAsync ( )
virtual

Receive datagram from the server (asynchronous)

Examples
udp_echo_client.cpp, and udp_multicast_client.cpp.

Definition at line 773 of file udp_client.cpp.

◆ Reconnect()

bool CppServer::Asio::UDPClient::Reconnect ( )
virtual

Reconnect the client (synchronous)

Returns
'true' if the client was successfully reconnected, 'false' if the client is already reconnected

Definition at line 267 of file udp_client.cpp.

◆ ReconnectAsync()

bool CppServer::Asio::UDPClient::ReconnectAsync ( )
virtual

Reconnect the client (asynchronous)

Returns
'true' if the client was successfully reconnected, 'false' if the client is already reconnected

Definition at line 408 of file udp_client.cpp.

◆ scheme()

const std::string& CppServer::Asio::UDPClient::scheme ( ) const
inlinenoexcept

Get the scheme name.

Definition at line 76 of file udp_client.h.

◆ Send() [1/8]

size_t CppServer::Asio::UDPClient::Send ( const asio::ip::udp::endpoint &  endpoint,
const void *  buffer,
size_t  size 
)
virtual

Send datagram to the given endpoint (synchronous)

Parameters
endpoint- Endpoint to send
buffer- Datagram buffer to send
size- Datagram buffer size
Returns
Size of sent datagram

Definition at line 481 of file udp_client.cpp.

◆ Send() [2/8]

size_t CppServer::Asio::UDPClient::Send ( const asio::ip::udp::endpoint &  endpoint,
const void *  buffer,
size_t  size,
const CppCommon::Timespan &  timeout 
)
virtual

Send datagram to the given endpoint with timeout (synchronous)

Parameters
endpoint- Endpoint to send
buffer- Datagram buffer to send
size- Datagram buffer size
timeout- Timeout
Returns
Size of sent datagram

Definition at line 523 of file udp_client.cpp.

◆ Send() [3/8]

virtual size_t CppServer::Asio::UDPClient::Send ( const asio::ip::udp::endpoint &  endpoint,
std::string_view  text 
)
inlinevirtual

Send text to the given endpoint (synchronous)

Parameters
endpoint- Endpoint to send
text- Text to send
Returns
Size of sent datagram

Definition at line 202 of file udp_client.h.

◆ Send() [4/8]

virtual size_t CppServer::Asio::UDPClient::Send ( const asio::ip::udp::endpoint &  endpoint,
std::string_view  text,
const CppCommon::Timespan &  timeout 
)
inlinevirtual

Send text to the given endpoint with timeout (synchronous)

Parameters
endpoint- Endpoint to send
text- Text to send
timeout- Timeout
Returns
Size of sent datagram

Definition at line 235 of file udp_client.h.

◆ Send() [5/8]

size_t CppServer::Asio::UDPClient::Send ( const void *  buffer,
size_t  size 
)
virtual

Send datagram to the connected server (synchronous)

Parameters
buffer- Datagram buffer to send
size- Datagram buffer size
Returns
Size of sent datagram

Definition at line 475 of file udp_client.cpp.

◆ Send() [6/8]

size_t CppServer::Asio::UDPClient::Send ( const void *  buffer,
size_t  size,
const CppCommon::Timespan &  timeout 
)
virtual

Send datagram to the connected server with timeout (synchronous)

Parameters
buffer- Datagram buffer to send
size- Datagram buffer size
timeout- Timeout
Returns
Size of sent datagram

Definition at line 517 of file udp_client.cpp.

◆ Send() [7/8]

virtual size_t CppServer::Asio::UDPClient::Send ( std::string_view  text)
inlinevirtual

Send text to the connected server (synchronous)

Parameters
text- Text to send
Returns
Size of sent datagram

Definition at line 187 of file udp_client.h.

◆ Send() [8/8]

virtual size_t CppServer::Asio::UDPClient::Send ( std::string_view  text,
const CppCommon::Timespan &  timeout 
)
inlinevirtual

Send text to the connected server with timeout (synchronous)

Parameters
text- Text to send
timeout- Timeout
Returns
Size of sent datagram

Definition at line 218 of file udp_client.h.

◆ SendAsync() [1/4]

bool CppServer::Asio::UDPClient::SendAsync ( const asio::ip::udp::endpoint &  endpoint,
const void *  buffer,
size_t  size 
)
virtual

Send datagram to the given endpoint (asynchronous)

Parameters
endpoint- Endpoint to send
buffer- Datagram buffer to send
size- Datagram buffer size
Returns
'true' if the datagram was successfully sent, 'false' if the datagram was not sent

Definition at line 593 of file udp_client.cpp.

◆ SendAsync() [2/4]

virtual bool CppServer::Asio::UDPClient::SendAsync ( const asio::ip::udp::endpoint &  endpoint,
std::string_view  text 
)
inlinevirtual

Send text to the given endpoint (asynchronous)

Parameters
endpoint- Endpoint to send
text- Text to send
Returns
'true' if the text was successfully sent, 'false' if the text was not sent

Definition at line 264 of file udp_client.h.

◆ SendAsync() [3/4]

bool CppServer::Asio::UDPClient::SendAsync ( const void *  buffer,
size_t  size 
)
virtual

Send datagram to the connected server (asynchronous)

Parameters
buffer- Datagram buffer to send
size- Datagram buffer size
Returns
'true' if the datagram was successfully sent, 'false' if the datagram was not sent

Definition at line 587 of file udp_client.cpp.

◆ SendAsync() [4/4]

virtual bool CppServer::Asio::UDPClient::SendAsync ( std::string_view  text)
inlinevirtual

Send text to the connected server (asynchronous)

Parameters
text- Text to send
Returns
'true' if the text was successfully sent, 'false' if the text was not sent

Definition at line 249 of file udp_client.h.

◆ service()

std::shared_ptr<Service>& CppServer::Asio::UDPClient::service ( )
inlinenoexcept

Get the Asio service.

Definition at line 63 of file udp_client.h.

◆ SetupMulticast()

void CppServer::Asio::UDPClient::SetupMulticast ( bool  enable)
inlinenoexcept

Setup option: bind the socket to the multicast UDP server.

Parameters
enable- Enable/disable option

Definition at line 321 of file udp_client.h.

◆ SetupReceiveBufferLimit()

void CppServer::Asio::UDPClient::SetupReceiveBufferLimit ( size_t  limit)
inlinenoexcept

Setup option: receive buffer limit.

The client will be disconnected if the receive buffer limit is met. Default is unlimited.

Parameters
limit- Receive buffer limit

Definition at line 329 of file udp_client.h.

◆ SetupReceiveBufferSize()

void CppServer::Asio::UDPClient::SetupReceiveBufferSize ( size_t  size)

Setup option: receive buffer size.

This option will setup SO_RCVBUF if the OS support this feature.

Parameters
size- Receive buffer size

Definition at line 111 of file udp_client.cpp.

◆ SetupReuseAddress()

void CppServer::Asio::UDPClient::SetupReuseAddress ( bool  enable)
inlinenoexcept

Setup option: reuse address.

This option will enable/disable SO_REUSEADDR if the OS support this feature.

Parameters
enable- Enable/disable option

Definition at line 309 of file udp_client.h.

◆ SetupReusePort()

void CppServer::Asio::UDPClient::SetupReusePort ( bool  enable)
inlinenoexcept

Setup option: reuse port.

This option will enable/disable SO_REUSEPORT if the OS support this feature.

Parameters
enable- Enable/disable option

Definition at line 316 of file udp_client.h.

◆ SetupSendBufferLimit()

void CppServer::Asio::UDPClient::SetupSendBufferLimit ( size_t  limit)
inlinenoexcept

Setup option: send buffer limit.

The client will be disconnected if the send buffer limit is met. Default is unlimited.

Parameters
limit- Send buffer limit

Definition at line 344 of file udp_client.h.

◆ SetupSendBufferSize()

void CppServer::Asio::UDPClient::SetupSendBufferSize ( size_t  size)

Setup option: send buffer size.

This option will setup SO_SNDBUF if the OS support this feature.

Parameters
size- Send buffer size

Definition at line 117 of file udp_client.cpp.

◆ socket()

asio::ip::udp::socket& CppServer::Asio::UDPClient::socket ( )
inlinenoexcept

Get the client socket.

Definition at line 71 of file udp_client.h.

◆ strand()

asio::io_service::strand& CppServer::Asio::UDPClient::strand ( )
inlinenoexcept

Get the Asio service strand for serialized handler execution.

Definition at line 67 of file udp_client.h.


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