#include <socket.h>
Public Member Functions | |
| UDPSocket ()=default | |
| UDPSocket (UDPSocket &&other) | |
| ~UDPSocket () | |
| UDPSocket & | operator= (UDPSocket &&other) |
| void | Init (bool ipv6) |
| void | Bind (Address addr) |
| void | Close () |
| Address | GetLocalAddress () |
| 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 |
Static Public Member Functions | |
| static UDPSocket | Create (Address addr) |
| create and bind a socket to an address | |
| static UDPSocket | CreateEphemeral (bool ipv6) |
Private Attributes | |
| int | m_handle = -1 |
| int | m_timeout_ms = -1 |
| unsigned short | m_addr_family = 0 |
|
default |
Referenced by UDPSocket(), Create(), CreateEphemeral(), and operator=().
|
inline |
References UDPSocket(), m_addr_family, m_handle, and m_timeout_ms.
|
inline |
| void UDPSocket::Bind | ( | Address | addr | ) |
References errorstream, Address::getAddress(), Address::getAddress6(), Address::getFamily(), Address::getPort(), Init(), Address::isIPv6(), LAST_SOCKET_ERR, m_addr_family, m_handle, SOCKET_ERR_STR, and tracestream.
Referenced by Create(), and TestSocket::testIPv6Socket().
| void UDPSocket::Close | ( | ) |
References m_handle.
Referenced by ~UDPSocket(), and operator=().
create and bind a socket to an address
References UDPSocket(), and Bind().
Referenced by CreateEphemeral(), Game::createServer(), run_dedicated_server(), TestConnection::testConnectSendReceive(), and TestSocket::testIPv4Socket().
|
inlinestatic |
References UDPSocket(), and Create().
Referenced by Client::connect(), recompress_map_database(), and TestConnection::testConnectSendReceive().
|
inline |
References m_handle.
| Address UDPSocket::GetLocalAddress | ( | ) |
References IPv6AddressBytes::bytes, LAST_SOCKET_ERR, m_handle, and SOCKET_ERR_STR.
Referenced by Game::createServer().
| void UDPSocket::Init | ( | bool | ipv6 | ) |
References g_sockets_initialized, LAST_SOCKET_ERR, m_addr_family, m_handle, setTimeoutMs(), SOCKET_ERR_STR, and verbosestream.
Referenced by Bind(), and TestSocket::testIPv6Socket().
References UDPSocket(), Close(), m_addr_family, m_handle, and m_timeout_ms.
| int UDPSocket::Receive | ( | Address & | sender, |
| void * | data, | ||
| int | size ) |
References IPv6AddressBytes::bytes, m_addr_family, m_handle, m_timeout_ms, MYMAX, and WaitData().
Referenced by TestSocket::testIPv4Socket(), and TestSocket::testIPv6Socket().
| 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 TestSocket::testIPv4Socket(), and TestSocket::testIPv6Socket().
| void UDPSocket::setTimeoutMs | ( | int | timeout_ms | ) |
| bool UDPSocket::WaitData | ( | int | timeout_ms | ) |
References LAST_SOCKET_ERR, m_handle, MYMAX, SOCKET_ERR_STR, and tracestream.
Referenced by Receive().
|
private |
Referenced by UDPSocket(), Bind(), Init(), operator=(), Receive(), and Send().
|
private |
Referenced by UDPSocket(), Bind(), Close(), GetHandle(), GetLocalAddress(), Init(), operator=(), Receive(), Send(), and WaitData().
|
private |
Referenced by UDPSocket(), operator=(), Receive(), and setTimeoutMs().