• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ udp::endpoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中boost::asio::ip::udp::endpoint的典型用法代码示例。如果您正苦于以下问题:C++ endpoint类的具体用法?C++ endpoint怎么用?C++ endpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了endpoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
}
开发者ID:dsingleton,项目名称:playdar,代码行数:31,代码来源:lan.cpp


示例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);
        }
    }
开发者ID:huangyt,项目名称:MyProjects,代码行数:31,代码来源:IpPool.cpp


示例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());
}
开发者ID:Estoque86,项目名称:Comparison_New_Simulators,代码行数:7,代码来源:face-uri.cpp


示例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));
	}
}
开发者ID:tfar,项目名称:ibce2eiot,代码行数:8,代码来源:iot_service.cpp


示例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());
  }
}
开发者ID:tfoerch,项目名称:LMP,代码行数:9,代码来源:Mgt_NetworkIF.cpp


示例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;
 }
开发者ID:moriarty,项目名称:raw_refbox_comm,代码行数:14,代码来源:capture_comm.cpp


示例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;
 }
开发者ID:moriarty,项目名称:raw_refbox_comm,代码行数:14,代码来源:capture_comm.cpp


示例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;
 }
开发者ID:moriarty,项目名称:raw_refbox_comm,代码行数:15,代码来源:capture_comm.cpp


示例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;
 }
开发者ID:moriarty,项目名称:raw_refbox_comm,代码行数:16,代码来源:capture_comm.cpp


示例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)
{
}
开发者ID:rtobar,项目名称:spead2,代码行数:9,代码来源:send_udp.cpp


示例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;
    }
开发者ID:huangyt,项目名称:MyProjects,代码行数:19,代码来源:IpPool.cpp


示例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());
    }
开发者ID:ijon,项目名称:blackhole,代码行数:11,代码来源:udp.cpp


示例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() );
}
开发者ID:dsingleton,项目名称:playdar,代码行数:14,代码来源:lan.cpp


示例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));
}
开发者ID:aasghari,项目名称:cse223bFinalProject,代码行数:13,代码来源:MessageHandler.cpp


示例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;
    }
开发者ID:moriarty,项目名称:raw_refbox_comm,代码行数:39,代码来源:capture_comm.cpp


示例16: ReceiveHandle

void ReceiveHandle(const boost::system::error_code e, const std::size_t size)
{
	StartReceive();

	if (e)
	{
		std::cout << e.value() << " " <<  e.message() << std::endl;
		return;
	}

	const std::string data(recv_buf.data(), size);
	
	std::cout << "Received: " << data << std::endl;

	std::vector<std::string> args;
	boost::algorithm::split(args, data, boost::algorithm::is_space());

	if (args.size() > 1)
	{
		boost::asio::ip::udp::resolver resolver(io_service);
		boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), args[0], args[1]);
		boost::asio::ip::udp::endpoint clientEp = *resolver.resolve(query);
		
		const std::string hello("ping!");
		g_pSocket->send_to(boost::asio::buffer(hello), clientEp);
		const std::string epStr = clientEp.address().to_string() + ":" + conv::cast<std::string>(clientEp.port());

		std::cout << "Sending ping! to: " << epStr << std::endl;
	}
	else
	{
		const std::string hello("pong!");
		g_pSocket->send_to(boost::asio::buffer(hello), ep);
		const std::string epStr = ep.address().to_string() + ":" + conv::cast<std::string>(ep.port());

		std::cout << "Sending pong! to: " << epStr << std::endl;
	}
}
开发者ID:Bia10,项目名称:clrn,代码行数:38,代码来源:UDPClient.cpp


示例17:

void
lan::receive_pang(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 PANG dropped." << endl;
        return;
    }
    string from_name = om["from_name"].get_str();
    cout << "Received UDP PANG from '" << from_name 
         << "' @ " << sender_endpoint.address().to_string()
         << endl;
    m_lannodes.erase(from_name);
}
开发者ID:dsingleton,项目名称:playdar,代码行数:15,代码来源:lan.cpp


示例18: encode_endpoint

void message::encode_endpoint(
    database::byte_buffer & body, const boost::asio::ip::udp::endpoint & ep
    )
{
    /**
     * Write the type.
     */
    body.write_uint16(attribute_type_endpoint);
    
    /**
     * Write the length.
     */
    body.write_uint16(ep.address().is_v4() ? 8 : 20);
    
    /**
     * Encode the padding.
     */
    body.write_uint8(0);
    
    /**
     * Write the ip address version.
     */
    body.write_uint8(
        ep.address().is_v4() ? constants::ipv4 : constants::ipv6
    );
    
    /**
     * Write the port.
     */
    body.write_uint16(ep.port());
    
    /**
     * Write the ip address.
     */
    body.write_address(ep.address());
}
开发者ID:ocminer,项目名称:vanillacoin,代码行数:36,代码来源:message.cpp


示例19: to_fc_ep

 fc::ip::endpoint to_fc_ep( const boost::asio::ip::udp::endpoint& e ) {
   return fc::ip::endpoint( e.address().to_v4().to_ulong(), e.port() );
 }
开发者ID:DerKorb,项目名称:fc,代码行数:3,代码来源:udp_socket.cpp


示例20: get_address_from_endpoint

std::string EMServer::get_address_from_endpoint(boost::asio::ip::udp::endpoint &endpoint) const
{
	return endpoint.address().to_string() + ":" + std::to_string(endpoint.port());
}
开发者ID:Fynx,项目名称:EMeeting,代码行数:4,代码来源:EMServer.cpp



注:本文中的boost::asio::ip::udp::endpoint类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ udp::socket类代码示例发布时间:2022-05-31
下一篇:
C++ tcp::socket类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap