AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AUdpSocket Class Reference

A bidirectional UDP socket.

#include <AUI/Network/AUdpSocket.h>

Public Member Functions#

 AUdpSocket (uint16_t port)
 Creates socket.
 
 AUdpSocket ()
 Creates socket with random port (used for "client" socket)
 
 AUdpSocket (const AUdpSocket &)=delete
 
void write (AByteBufferView buf, const AInet4Address &dst)
 Sends data by address.
 
void read (AByteBuffer &buf, AInet4Address &dst)
 Read data.
 
- Public Member Functions inherited from AAbstractSocket
 AAbstractSocket (const AAbstractSocket &)=delete
 
void close ()
 
void setTimeout (int secs)
 
const AInet4AddressgetAddress () const
 

Protected Member Functions#

int createSocket () override
 Creates socket handle.
 
- Protected Member Functions inherited from AAbstractSocket
int getHandle () const
 
 AAbstractSocket (int handle, const AInet4Address &selfAddress)
 
void init ()
 Initialise socket.
 
void bind (uint16_t bindingPort)
 Binds socket for port. Used for ATcpServerSocket and AUdpSocket.
 

Additional Inherited Members#

- Static Protected Member Functions inherited from AAbstractSocket
static AString getErrorString ()
 
static void handleError (const AString &message, int code)
 

Constructor & Destructor Documentation#

◆ AUdpSocket()#

AUdpSocket::AUdpSocket ( uint16_t port)
Parameters
portport

Member Function Documentation#

◆ createSocket()#

int AUdpSocket::createSocket ( )
overrideprotectedvirtual

Implements AAbstractSocket.

◆ read()#

void AUdpSocket::read ( AByteBuffer & buf,
AInet4Address & dst )
Parameters
buf(out) received data
dst(out) sender address

◆ write()#

void AUdpSocket::write ( AByteBufferView buf,
const AInet4Address & dst )
Parameters
bufdata buffer
dstdestination delivery address