Open 3D Engine AzNetworking API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzNetworking::UdpSocket Class Reference

wrapper class for managing UDP sockets. More...

#include <UdpSocket.h>

Inherited by AzNetworking::DtlsSocket.

Public Types

enum class  CanAcceptConnections { False , True }
 

Public Member Functions

virtual bool IsEncrypted () const
 
virtual DtlsEndpoint::ConnectResult ConnectDtlsEndpoint (DtlsEndpoint &dtlsEndpoint, const IpAddress &address, UdpPacketEncodingBuffer &outDtlsData) const
 
virtual DtlsEndpoint::ConnectResult AcceptDtlsEndpoint (DtlsEndpoint &dtlsEndpoint, const IpAddress &address) const
 
virtual bool Open (uint16_t port, CanAcceptConnections canAccept, TrustZone trustZone)
 
virtual void Close ()
 Closes an open socket.
 
bool IsOpen () const
 
int32_t Send (const IpAddress &address, const uint8_t *data, uint32_t size, bool encrypt, DtlsEndpoint &dtlsEndpoint, const ConnectionQuality &connectionQuality) const
 
int32_t Receive (IpAddress &outAddress, uint8_t *outData, uint32_t size) const
 
SocketFd GetSocketFd () const
 
uint32_t GetSentPackets () const
 
uint32_t GetSentBytes () const
 
uint32_t GetSentPacketsEncrypted () const
 
uint32_t GetSentBytesEncryptionInflation () const
 
uint32_t GetRecvPackets () const
 
uint32_t GetRecvBytes () const
 

Protected Attributes

uint32_t m_sentPacketsEncrypted = 0
 
uint32_t m_sentBytesEncryptionInflation = 0
 

Detailed Description

wrapper class for managing UDP sockets.

Member Function Documentation

◆ AcceptDtlsEndpoint()

virtual DtlsEndpoint::ConnectResult AzNetworking::UdpSocket::AcceptDtlsEndpoint ( DtlsEndpoint dtlsEndpoint,
const IpAddress address 
) const
virtual

Accepts an encryption socket wrapper.

Parameters
dtlsEndpointthe encryption wrapper instance to create a connection over
addressthe IP address of the endpoint to connect to
Returns
a connect result specifying whether the connection is still pending, failed, or complete

Reimplemented in AzNetworking::DtlsSocket.

◆ Close()

virtual void AzNetworking::UdpSocket::Close ( )
virtual

Closes an open socket.

Reimplemented in AzNetworking::DtlsSocket.

◆ ConnectDtlsEndpoint()

virtual DtlsEndpoint::ConnectResult AzNetworking::UdpSocket::ConnectDtlsEndpoint ( DtlsEndpoint dtlsEndpoint,
const IpAddress address,
UdpPacketEncodingBuffer outDtlsData 
) const
virtual

Creates an encryption socket wrapper.

Parameters
dtlsEndpointthe encryption wrapper instance to create a connection over
addressthe IP address of the endpoint to connect to
outDtlsDatadata buffer to store the dtls handshake packet
Returns
a connect result specifying whether the connection is still pending, failed, or complete

Reimplemented in AzNetworking::DtlsSocket.

◆ GetRecvBytes()

uint32_t AzNetworking::UdpSocket::GetRecvBytes ( ) const
inline

Returns the total number of bytes received on this socket.

Returns
the total number of bytes received on this socket

◆ GetRecvPackets()

uint32_t AzNetworking::UdpSocket::GetRecvPackets ( ) const
inline

Returns the total number of packets received on this socket.

Returns
the total number of packets received on this socket

◆ GetSentBytes()

uint32_t AzNetworking::UdpSocket::GetSentBytes ( ) const
inline

Returns the total number of bytes sent on this socket.

Returns
the total number of bytes sent on this socket

◆ GetSentBytesEncryptionInflation()

uint32_t AzNetworking::UdpSocket::GetSentBytesEncryptionInflation ( ) const
inline

Returns the total number of additional bytes sent on this socket due to SSL encryption.

Returns
the total number of additional bytes sent on this socket due to SSL encryption

◆ GetSentPackets()

uint32_t AzNetworking::UdpSocket::GetSentPackets ( ) const
inline

Returns the total number of packets sent on this socket.

Returns
the total number of packets sent on this socket

◆ GetSentPacketsEncrypted()

uint32_t AzNetworking::UdpSocket::GetSentPacketsEncrypted ( ) const
inline

Returns the total number of encrypted packets sent on this socket.

Returns
the total number of encrypted packets sent on this socket

◆ GetSocketFd()

SocketFd AzNetworking::UdpSocket::GetSocketFd ( ) const
inline

Returns the underlying socket file descriptor.

Returns
the underlying socket file descriptor

◆ IsEncrypted()

virtual bool AzNetworking::UdpSocket::IsEncrypted ( ) const
virtual

Returns true if this is an encrypted socket, false if not.

Returns
boolean true if this is an encrypted socket, false if not

Reimplemented in AzNetworking::DtlsSocket.

◆ IsOpen()

bool AzNetworking::UdpSocket::IsOpen ( ) const
inline

Returns true if the UDP socket is currently in an open state.

Returns
boolean true if the socket is in a connected state

◆ Open()

virtual bool AzNetworking::UdpSocket::Open ( uint16_t  port,
CanAcceptConnections  canAccept,
TrustZone  trustZone 
)
virtual

Opens the UDP socket on the given port.

Parameters
portthe port number to open the UDP socket on, 0 will bind to any available port
canAcceptif true, the socket will be opened in a way that allows accepting incoming connections
trustZonefor encrypted connections, the level of trust we associate with this connection (internal or external)
Returns
boolean true on success

Reimplemented in AzNetworking::DtlsSocket.

◆ Receive()

int32_t AzNetworking::UdpSocket::Receive ( IpAddress outAddress,
uint8_t *  outData,
uint32_t  size 
) const

Receives a payload from the UDP socket.

Parameters
outAddresson success, the address of the endpoint that sent the data
outDataon success, address to write the received data to
sizemaximum size the output buffer supports for receiving
Returns
number of bytes received, <= 0 on error

◆ Send()

int32_t AzNetworking::UdpSocket::Send ( const IpAddress address,
const uint8_t *  data,
uint32_t  size,
bool  encrypt,
DtlsEndpoint dtlsEndpoint,
const ConnectionQuality connectionQuality 
) const

Sends a single payload over the UDP socket to the connected endpoint.

Parameters
addressthe address to send the payload to
datapointer to the data to send
sizesize of the payload in bytes
encryptsignals that the payload should be encrypted before transmitting if encryption is supported
dtlsEndpointdata required for DTLS encryption
connectionQualitydebug connection quality parameters
Returns
number of bytes sent, <= 0 on error

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