本文整理汇总了C++中boost::asio::ip::udp::endpoint::address方法的典型用法代码示例。如果您正苦于以下问题:C++ endpoint::address方法的具体用法?C++ endpoint::address怎么用?C++ endpoint::address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::ip::udp::endpoint
的用法示例。
在下文中一共展示了endpoint::address方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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());
}
示例2: 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 );
}
示例3: 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));
}
}
示例4:
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());
}
}
示例5: handleReceivedUDP
void handleReceivedUDP(const boost::system::error_code& error,
std::size_t bytes_transferred)
{
if (error == boost::asio::error::operation_aborted)
return; /* we're done */
if (error) {
printf("SC_UdpInPort: received error - %s", error.message().c_str());
startReceiveUDP();
return;
}
if (mWorld->mDumpOSC) dumpOSC(mWorld->mDumpOSC, bytes_transferred, recvBuffer.data());
OSC_Packet * packet = (OSC_Packet*)malloc(sizeof(OSC_Packet));
packet->mReplyAddr.mProtocol = kUDP;
packet->mReplyAddr.mAddress = remoteEndpoint.address();
packet->mReplyAddr.mPort = remoteEndpoint.port();
packet->mReplyAddr.mSocket = udpSocket.native_handle();
packet->mReplyAddr.mReplyFunc = udp_reply_func;
packet->mReplyAddr.mReplyData = (void*)&udpSocket;
packet->mSize = bytes_transferred;
if (!UnrollOSCPacket(mWorld, bytes_transferred, recvBuffer.data(), packet))
free(packet);
startReceiveUDP();
}
示例6: 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);
}
}
示例7: 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));
}
示例8: lock
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;
}
示例9: 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() );
}
示例10:
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;
}
示例11:
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);
}
示例12: 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());
}
示例13: 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;
}
示例14: 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;
}
}
示例15:
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() );
}