本文整理汇总了C++中boost::asio::ip::udp::endpoint类的典型用法代码示例。如果您正苦于以下问题:C++ endpoint类的具体用法?C++ endpoint怎么用?C++ endpoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了endpoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: time
void
lan::receive_ping(map<string,Value> & om,
const boost::asio::ip::udp::endpoint & sender_endpoint)
{
if(om.find("from_name")==om.end() || om["from_name"].type()!=str_type)
{
cout << "Malformed UDP PING dropped." << endl;
return;
}
// ignore pings sent from ourselves:
if(om["from_name"]==m_pap->hostname()) return;
if(om.find("http_port")==om.end() || om["http_port"].type()!=int_type)
{
cout << "Malformed UDP PING dropped." << endl;
return;
}
string from_name = om["from_name"].get_str();
cout << "Received UDP PING from '" << from_name
<< "' @ " << sender_endpoint.address().to_string()
<< endl;
ostringstream hbase;
hbase << "http://" << sender_endpoint.address().to_string()
<< ":" << om["http_port"].get_int();
lannode node;
time(&node.lastdate);
node.name = from_name;
node.http_base = hbase.str();
node.udp_ep = sender_endpoint;
m_lannodes[from_name] = node;
send_pong( sender_endpoint );
}
示例2: OnDisConnect
void IpPool::OnDisConnect(const boost::asio::ip::udp::endpoint& end_point, bool is_active)
{
if (is_running_ == false) return;
LOG4CPLUS_INFO_LOG(logger_ippool, "IpPool::OnDisConnect Endpoint=" << end_point);
protocol::SocketAddr socket_addr(end_point.address().to_v4().to_ulong(), end_point.port());
std::map<protocol::SocketAddr, CandidatePeer::p>::iterator iter = candidate_peers_.find(socket_addr);
if (iter == candidate_peers_.end())
return;
CandidatePeer::p peer = iter->second;
assert(peer);
IPPoolIndexUpdating updating(peer, shared_from_this());
peer->last_active_time_ = framework::timer::TickCounter::tick_count();
// reset last_connect_time_ to avoid re-connecting the peer immediately
peer->last_connect_time_ = peer->last_active_time_;
peer->is_connecting_ = false;
peer->is_connected_ = false;
if (is_active)
{
protocol::CloseSessionPacket packet(protocol::Packet::NewTransactionID(),
protocol::PEER_VERSION, end_point);
AppModule::Inst()->DoSendPacket(packet, protocol::PEER_VERSION);
}
}
示例3:
FaceUri::FaceUri(const boost::asio::ip::udp::endpoint& endpoint)
{
m_isV6 = endpoint.address().is_v6();
m_scheme = m_isV6 ? "udp6" : "udp4";
m_host = endpoint.address().to_string();
m_port = boost::lexical_cast<std::string>(endpoint.port());
}
示例4: handleDelayedAuthentication
void IoTService::handleDelayedAuthentication(boost::asio::ip::udp::endpoint remoteEndpoint, std::vector<uint8_t> data, std::array<uint8_t, 14> taPrefix, ec taKey) {
std::array<uint8_t, 16> remoteAddress = remoteEndpoint.address().to_v6().to_bytes();
if (memcmp(remoteAddress.data(), taPrefix.data(), 14) == 0) {
LOG(INFO) << "Received TA key for prefix " << remoteEndpoint.address().to_v6();
authenticateMessage(remoteEndpoint.address().to_v6(), data, taKey);
lookupCache_->onTAKeyAvailable.disconnect(boost::bind(&IoTService::handleDelayedAuthentication, this, remoteEndpoint, data, _1, _2));
}
}
示例5:
void NetworkIF_i::IPCCAdjDiscoveredFtor::do_process(
const boost::asio::ip::udp::endpoint& sender_endpointl)
{
if (sender_endpointl.address().is_v4())
{
m_networkIF.createIPCC(sender_endpointl.address().to_v4().to_ulong(),
sender_endpointl.port());
}
}
示例6: receive_benchmark_state
static void
receive_benchmark_state (boost::asio::ip::udp::endpoint& endpoint,
uint16_t comp_id,
uint16_t msg_type,
shared_ptr<const roah_rsbb_msgs::BenchmarkState> msg)
{
cout << "Received BenchmarkState from " << endpoint.address().to_string()
<< ":" << endpoint.port()
<< ", COMP_ID " << comp_id
<< ", MSG_TYPE " << msg_type << endl
<< " benchmark_type: " << msg->benchmark_type() << endl
<< " benchmark_state: " << msg->benchmark_state() << endl
<< flush;
}
示例7: receive_robot_state
static void
receive_robot_state (boost::asio::ip::udp::endpoint& endpoint,
uint16_t comp_id,
uint16_t msg_type,
shared_ptr<const roah_rsbb_msgs::RobotState> msg)
{
cout << "Received RobotState from " << endpoint.address().to_string()
<< ":" << endpoint.port()
<< ", COMP_ID " << comp_id
<< ", MSG_TYPE " << msg_type << endl
<< " time: " << msg->time().sec() << "." << msg->time().nsec() << endl
<< " messages_saved: " << msg->messages_saved() << endl
<< flush;
}
示例8: receive_robot_beacon
static void
receive_robot_beacon (boost::asio::ip::udp::endpoint& endpoint,
uint16_t comp_id,
uint16_t msg_type,
shared_ptr<const roah_rsbb_msgs::RobotBeacon> msg)
{
cout << "Received RobotBeacon from " << endpoint.address().to_string()
<< ":" << endpoint.port()
<< ", COMP_ID " << comp_id
<< ", MSG_TYPE " << msg_type << endl
<< " team_name: " << msg->team_name() << endl
<< " robot_name: " << msg->robot_name() << endl
<< " time: " << msg->time().sec() << "." << msg->time().nsec() << endl
<< flush;
}
示例9: receive_tablet_beacon
static void
receive_tablet_beacon (boost::asio::ip::udp::endpoint& endpoint,
uint16_t comp_id,
uint16_t msg_type,
shared_ptr<const roah_rsbb_msgs::TabletBeacon> msg)
{
cout << "Received TabletBeacon from " << endpoint.address().to_string()
<< ":" << endpoint.port()
<< ", COMP_ID " << comp_id
<< ", MSG_TYPE " << msg_type << endl
<< " last_call: " << msg->last_call().sec() << "." << msg->last_call().nsec() << endl
<< " last_pos: " << msg->last_pos().sec() << "." << msg->last_pos().nsec() << endl
<< " x: " << msg->x() << endl
<< " y: " << msg->y() << endl
<< flush;
}
示例10:
udp_stream::udp_stream(
boost::asio::io_service &io_service,
const boost::asio::ip::udp::endpoint &endpoint,
const stream_config &config,
std::size_t buffer_size)
: udp_stream(boost::asio::ip::udp::socket(io_service, endpoint.protocol()),
endpoint, config, buffer_size)
{
}
示例11: OnConnectSucced
void IpPool::OnConnectSucced(const boost::asio::ip::udp::endpoint& end_point)
{
if (is_running_ == false) return;
LOG4CPLUS_INFO_LOG(logger_ippool, "IpPool::OnConnectSucced Endpoint=" << end_point);
protocol::SocketAddr socket_addr(end_point.address().to_v4().to_ulong(), end_point.port());
std::map<protocol::SocketAddr, CandidatePeer::p>::iterator iter = candidate_peers_.find(socket_addr);
if (iter == candidate_peers_.end())
return;
CandidatePeer::p peer = iter->second;
assert(peer);
IPPoolIndexUpdating updating(peer, shared_from_this());
peer->last_active_time_ = framework::timer::TickCounter::tick_count();
peer->is_connecting_ = false;
peer->is_connected_ = true;
}
示例12: socket
blocking_t(const std::string& host, std::uint16_t port) :
io_service(),
socket(io_service)
{
boost::asio::ip::udp::resolver resolver(io_service);
boost::asio::ip::udp::resolver::query query(host, boost::lexical_cast<std::string>(port),
boost::asio::ip::udp::resolver::query::flags::numeric_service);
endpoint = *resolver.resolve(query);
socket.open(endpoint.protocol());
}
示例13: Pair
/// pong reply back to specific user
void
lan::send_pong(boost::asio::ip::udp::endpoint sender_endpoint)
{
cout << "LAN sending pong back to "
<< sender_endpoint.address().to_string() <<".." << endl;
Object o;
o.push_back( Pair("_msgtype", "pong") );
o.push_back( Pair("from_name", m_pap->hostname()) );
o.push_back( Pair("http_port", 8888/*m_pap->get("http_port", 8888)*/) );
ostringstream os;
write_formatted( o, os );
async_send( &sender_endpoint, os.str() );
}
示例14: requestMissingData
void MessageHandler::requestMissingData(const boost::asio::ip::udp::endpoint& destination)
{
debug<<"Requesting missing data from"<<destination.address().to_string()<<std::endl;
::Network::MsgWrapper missDataWrap;
missDataWrap.mutable_missingdata();
debug<<"requesting missing with clock"<<this->myClock<<std::endl;
missDataWrap.set_vectorclock(this->myClock.encode());
boost::shared_ptr<std::string> msgShardPtr(new std::string(missDataWrap.SerializeAsString()));
socket_.async_send_to(boost::asio::buffer(*msgShardPtr), destination,
boost::bind(&MessageHandler::handle_send_to, this, msgShardPtr,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
示例15: receive_rsbb_beacon
void
receive_rsbb_beacon (boost::asio::ip::udp::endpoint& endpoint,
uint16_t comp_id,
uint16_t msg_type,
shared_ptr<const roah_rsbb_msgs::RoahRsbbBeacon> rsbb_beacon)
{
cout << "Received RoahRsbbBeacon from " << endpoint.address().to_string()
<< ":" << endpoint.port()
<< ", COMP_ID " << comp_id
<< ", MSG_TYPE " << msg_type << endl;
unsigned short connect_port = 0;
for (auto const& bt : rsbb_beacon->benchmarking_teams()) {
cout << " team_name: " << bt.team_name()
<< ", robot_name: " << bt.robot_name()
<< ", rsbb_port: " << bt.rsbb_port() << endl;
if ( (bt.team_name() == TEAM_NAME) && (bt.robot_name() == ROBOT_NAME)) {
connect_port = bt.rsbb_port();
// break; // Commented to show all entries
}
}
lock_guard<mutex> lock (private_channel_mutex_);
if (connect_port != (private_channel_ ? private_channel_->port() : 0)) {
if (private_channel_) {
cout << "Disconnecting private channel" << endl;
private_channel_.reset();
}
if (connect_port) {
cout << "Connecting private channel to " << endpoint.address().to_string()
<< ":" << connect_port << endl;
private_channel_ = make_shared<PrivateChannel<CerrErrorHandler>> (endpoint.address().to_string(), connect_port, CRYPTO_KEY, CRYPTO_CIPHER);
private_channel_->signal_benchmark_state_received().connect (&DumpComm::receive_benchmark_state);
private_channel_->signal_robot_state_received().connect (&DumpComm::receive_robot_state);
}
}
cout << flush;
}