6#include "../AsyncSocketBase.hxx"
18 asio::error_code errorCode;
19 mSocket.open(address.is_v6() ? asio::ip::udp::v6() : asio::ip::udp::v4(), errorCode);
30 asio::error_code errorCode;
35 asio::ip::udp::resolver::results_type results = resolver.resolve(mSocket.local_endpoint().protocol(), address, service.
c_str());
36 asio::ip::udp::resolver::results_type::const_iterator endpoint_iterator = results.begin();
37 asio::ip::udp::resolver::results_type::const_iterator end = results.end();
40 if(endpoint_iterator == end)
42 return asio::error::host_not_found;
46 mRemoteEndpoint = endpoint_iterator->endpoint();
59 asio::error_code errorCode;
60 mSocket.send_to(asio::buffer(buffer, size), mRemoteEndpoint, 0, errorCode);
67 asio::error_code errorCode;
68 mSocket.send_to(buffers, mRemoteEndpoint, 0, errorCode);
73TurnUdpSocket::rawRead(
unsigned int timeout,
unsigned int* bytesRead, asio::ip::address* sourceAddress,
unsigned short* sourcePort)
89 *sourceAddress = mSenderEndpoint.address();
93 *sourcePort = mSenderEndpoint.port();
static void setExclusiveAddressUse(asio::ip::udp::socket &socket)
For a UDP socket, between open() and bind().
const asio::ip::address & getAddress() const
unsigned int getPort() const
void setPort(unsigned int port)
void setAddress(const asio::ip::address &address)
void setTransportType(TransportType transport)
void handleRawRead(const asio::error_code &errorCode, size_t bytesRead)
asio::io_context mIOService
asio::error_code mReadErrorCode
void startReadTimer(unsigned int timeout)
StunTuple mConnectedTuple
virtual void cancelSocket()
TurnUdpSocket(const asio::ip::address &address, unsigned short port)
virtual asio::error_code rawRead(unsigned int timeout, unsigned int *bytesRead, asio::ip::address *sourceAddress=0, unsigned short *sourcePort=0)
virtual asio::error_code rawWrite(const char *buffer, unsigned int size)
virtual asio::error_code connect(const std::string &address, unsigned short port)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
const char * c_str() const
Returns a null-terminated string representing.