本文整理汇总了C++中boost::asio::ip::udp::socket::async_receive_from方法的典型用法代码示例。如果您正苦于以下问题:C++ socket::async_receive_from方法的具体用法?C++ socket::async_receive_from怎么用?C++ socket::async_receive_from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::ip::udp::socket
的用法示例。
在下文中一共展示了socket::async_receive_from方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receive_next
void receive_next() {
m_multicast_socket.async_receive_from
(boost::asio::buffer(m_frame_data, sizeof(m_frame_data)), m_frame_sender,
boost::bind(&garmin_radar::handle_frame, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
示例2: 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);
}
示例3: start_receive
void start_receive(){
socket.async_receive_from(
boost::asio::buffer(recv_arr), receiver_endpoint,
boost::bind(
&sAudioReceiver::handle_receive,
this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred
)
);
}
示例4: handle_receive_from
void handle_receive_from(
const boost::system::error_code& error,
size_t bytes_recvd)
{
if (!error)
{
std::cout.write(data_, bytes_recvd);
std::cout << std::endl;
socket_.async_receive_from(
boost::asio::buffer(data_, max_length), sender_endpoint_,
boost::bind(&receiver::handle_receive_from, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
}
示例5: receiver
receiver(boost::asio::io_service& io_service,
const boost::asio::ip::address& listen_address,
const boost::asio::ip::address& multicast_address)
: socket_(io_service)
{
// Create the socket so that multiple may be bound to the same address.
boost::asio::ip::udp::endpoint listen_endpoint(
listen_address, multicast_port);
socket_.open(listen_endpoint.protocol());
socket_.set_option(boost::asio::ip::udp::socket::reuse_address(true));
socket_.bind(listen_endpoint);
// Join the multicast group.
socket_.set_option(
boost::asio::ip::multicast::join_group(multicast_address));
socket_.async_receive_from(
boost::asio::buffer(data_, max_length), sender_endpoint_,
boost::bind(&receiver::handle_receive_from, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
示例6: Listen
void DiscoveryServer::Listen() {
m_socket.async_receive_from(
boost::asio::buffer(m_recv_buffer), m_remote_endpoint,
boost::bind(&DiscoveryServer::HandleReceive, this,
boost::asio::placeholders::error));
}