33 SimpleUDP(
int addressFamily,
size_t sendBufSize = UDP_BUFFER_SIZE,
size_t receiveBufSize = UDP_BUFFER_SIZE,
bool nonBlocking =
true);
43 SimpleUDP(
bool IPV4 =
true,
size_t sendBufSize = UDP_BUFFER_SIZE,
size_t receiveBufSize = UDP_BUFFER_SIZE,
bool nonBlocking =
true);
55 SimpleUDP(
const char* host,
unsigned short port,
size_t sendBufSize = UDP_BUFFER_SIZE,
size_t receiveBufSize = UDP_BUFFER_SIZE,
bool nonBlocking =
true);
65 int Connect(
const sockaddr* address,
size_t addressLength);
86 int Bind(
const sockaddr* address,
size_t addressLength)
const;
99 int SendData(
const uint8_t* data,
size_t dataLen)
const;
109 int SendDataTo(
const sockaddr* address,
size_t addressLength,
const uint8_t* data,
size_t dataLen)
const;
152 void CreateSocket(
int addressFamily,
size_t sendBufSize,
size_t receiveBufSize,
bool nonBlocking);
153 int GetUnderlyingSocket()
const {
return m_socket; }
154 void SetUnderlyingSocket(
int socket) { m_socket = socket; }
157 mutable bool m_connected;
159 unsigned short m_port;
int ConnectToHost(const char *hostIP, unsigned short port) const
An easy way to connect to host.
int ReceiveData(uint8_t *buffer, size_t bufferLen) const
Receive data from unique address specified in ConnectWithServer call. this function is equivalent to ...
int ConnectToLocalHost(unsigned short port) const
An easy way to connect to 127.0.0.1 or ::1 based on m_addressFamily.
int SendDataTo(const sockaddr *address, size_t addressLength, const uint8_t *data, size_t dataLen) const
Send data to server.
SimpleUDP(int addressFamily, size_t sendBufSize=UDP_BUFFER_SIZE, size_t receiveBufSize=UDP_BUFFER_SIZE, bool nonBlocking=true)
Constructor of SimpleUDP.
SimpleUDP(bool IPV4=true, size_t sendBufSize=UDP_BUFFER_SIZE, size_t receiveBufSize=UDP_BUFFER_SIZE, bool nonBlocking=true)
An easy constructor of an IPV4 or IPV6 SimpleUDP.
int ReceiveDataFrom(sockaddr *address, size_t *addressLength, uint8_t *buffer, size_t bufferLen) const
Receive data from network.
int BindToLocalHost(unsigned short port) const
An easy way to bind to localhost.
SimpleUDP(const char *host, unsigned short port, size_t sendBufSize=UDP_BUFFER_SIZE, size_t receiveBufSize=UDP_BUFFER_SIZE, bool nonBlocking=true)
An easy constructor of SimpleUDP based on host and port.
int Connect(const sockaddr *address, size_t addressLength)
Connect underlying udp socket to server specified in address.
int SendDataToLocalHost(const uint8_t *data, size_t dataLen, unsigned short port) const
An easy way to send data to localhost, when the underlying udp is connected, call this function will ...
int Bind(const sockaddr *address, size_t addressLength) const
Bind underlying udp socket to an address.
int GetAddressFamily() const
int SendData(const uint8_t *data, size_t dataLen) const
Send data to server without specifying address, only usable if hostIP and port are available.
static const size_t UDP_BUFFER_SIZE
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String