Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
UDPSocket Class Reference

#include <socket.h>

Public Member Functions

 UDPSocket ()=default
 
 UDPSocket (bool ipv6)
 
 ~UDPSocket ()
 
bool init (bool ipv6, bool noExceptions=false)
 
void Bind (Address addr)
 
void Send (const Address &destination, const void *data, int size)
 
int Receive (Address &sender, void *data, int size)
 
void setTimeoutMs (int timeout_ms)
 
bool WaitData (int timeout_ms)
 
int GetHandle () const
 

Private Attributes

int m_handle = -1
 
int m_timeout_ms = -1
 
unsigned short m_addr_family = 0
 

Constructor & Destructor Documentation

◆ UDPSocket() [1/2]

UDPSocket::UDPSocket ( )
default

◆ UDPSocket() [2/2]

UDPSocket::UDPSocket ( bool ipv6)

References init().

+ Here is the call graph for this function:

◆ ~UDPSocket()

UDPSocket::~UDPSocket ( )

References m_handle.

Member Function Documentation

◆ Bind()

void UDPSocket::Bind ( Address addr)

References errorstream, Address::getAddress(), Address::getAddress6(), Address::getFamily(), Address::getPort(), LAST_SOCKET_ERR, m_addr_family, m_handle, SOCKET_ERR_STR, and tracestream.

Referenced by con::ConnectionSendThread::connect(), con::ConnectionSendThread::serve(), TestSocket::testIPv4Socket(), and TestSocket::testIPv6Socket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHandle()

int UDPSocket::GetHandle ( ) const
inline

References m_handle.

Referenced by con::Connection::getDesc().

+ Here is the caller graph for this function:

◆ init()

bool UDPSocket::init ( bool ipv6,
bool noExceptions = false )

References g_sockets_initialized, LAST_SOCKET_ERR, m_addr_family, m_handle, setTimeoutMs(), SOCKET_ERR_STR, and verbosestream.

Referenced by UDPSocket(), and TestSocket::testIPv6Socket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Receive()

int UDPSocket::Receive ( Address & sender,
void * data,
int size )

References m_addr_family, m_handle, m_timeout_ms, MYMAX, and WaitData().

Referenced by con::ConnectionReceiveThread::receive(), TestSocket::testIPv4Socket(), and TestSocket::testIPv6Socket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Send()

void UDPSocket::Send ( const Address & destination,
const void * data,
int size )

References Address::getAddress(), Address::getAddress6(), Address::getFamily(), Address::getPort(), INTERNET_SIMULATOR, INTERNET_SIMULATOR_PACKET_LOSS, m_addr_family, m_handle, myrand(), and tracestream.

Referenced by con::ConnectionSendThread::rawSend(), TestSocket::testIPv4Socket(), and TestSocket::testIPv6Socket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTimeoutMs()

void UDPSocket::setTimeoutMs ( int timeout_ms)

References m_timeout_ms.

Referenced by con::Connection::Connection(), and init().

+ Here is the caller graph for this function:

◆ WaitData()

bool UDPSocket::WaitData ( int timeout_ms)

References LAST_SOCKET_ERR, m_handle, MYMAX, SOCKET_ERR_STR, and tracestream.

Referenced by Receive().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_addr_family

unsigned short UDPSocket::m_addr_family = 0
private

Referenced by Bind(), init(), Receive(), and Send().

◆ m_handle

int UDPSocket::m_handle = -1
private

◆ m_timeout_ms

int UDPSocket::m_timeout_ms = -1
private

Referenced by Receive(), and setTimeoutMs().


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