本文整理汇总了C++中boost::asio::ip::udp::socket::async_send_to方法的典型用法代码示例。如果您正苦于以下问题:C++ socket::async_send_to方法的具体用法?C++ socket::async_send_to怎么用?C++ socket::async_send_to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::ip::udp::socket
的用法示例。
在下文中一共展示了socket::async_send_to方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendTestRequest
void STUNClient::sendTestRequest(
boost::asio::ip::udp::socket& sock,
OSS::IPAddress& dest,
int testNum)
{
//std::cout << "Sending TEST " << testNum << " " << sock.local_endpoint().address().to_string()
// << "->" << dest.toIpPortString() << std::endl;
StunAtrString username;
StunAtrString password;
username.sizeValue = 0;
password.sizeValue = 0;
bool changePort=false;
bool changeIP=false;
switch (testNum)
{
case 1:
case 10:
case 11:
break;
case 2:
//changePort=true;
changeIP=true;
break;
case 3:
changePort=true;
break;
case 4:
changeIP=true;
break;
case 5:
break;
default:
OSS_ASSERT(false);
}
StunMessage req;
memset(&req, 0, sizeof(StunMessage));
stunBuildReqSimple(&req, username, changePort , changeIP , testNum);
char buf[STUN_MAX_MESSAGE_SIZE];
int len = STUN_MAX_MESSAGE_SIZE;
len = stunEncodeMessage(req, buf, len, password, false);
sock.async_send_to(boost::asio::buffer(buf, len),
boost::asio::ip::udp::endpoint(dest.address(), dest.getPort()),
boost::bind(&STUNClient::handleWrite, shared_from_this(),
boost::asio::placeholders::error));
sock.async_receive_from(boost::asio::buffer(_buffer), _senderEndPoint,
boost::bind(&STUNClient::handleReadNatType, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
_semReadEvent.tryWait(10);
}
示例2: send_request
void send_request(){
socket.async_send_to(boost::asio::buffer(send_arr, 5), receiver_endpoint,
boost::bind(&sAudioReceiver::handle_send, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
)
);
}