本文整理汇总了C++中boost::asio::ip::udp::socket::async_receive方法的典型用法代码示例。如果您正苦于以下问题:C++ socket::async_receive方法的具体用法?C++ socket::async_receive怎么用?C++ socket::async_receive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::ip::udp::socket
的用法示例。
在下文中一共展示了socket::async_receive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_receive
void handle_receive(const boost::system::error_code& error, size_t received_bytes) {
this->sendto(buf,received_bytes);
lsock.async_receive(
boost::asio::buffer(buf,MAX_BUF),
boost::bind(&interfaces::handle_receive, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
示例2: interfaces
interfaces() {
memset(data,0,MAX_LINKS*sizeof(struct info));
memset(buf,0,MAX_BUF);
lsock.open(boost::asio::ip::udp::v4());
lsock.bind(boost::asio::ip::udp::endpoint(boost::asio::ip::address::from_string("127.0.0.1"),10000));
lsock.async_receive(
boost::asio::buffer(buf,MAX_BUF),
boost::bind(&interfaces::handle_receive, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
boost::thread t = boost::thread (boost::bind(&boost::asio::io_service::run, &iol));
}