예제 #1
0
파일: lan.cpp 프로젝트: dsingleton/playdar
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
0
    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
0
	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();
	}
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());
}
예제 #5
0
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));
	}
}
예제 #6
0
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());
  }
}
예제 #7
0
 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;
 }
예제 #8
0
 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;
 }
예제 #9
0
 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;
 }
예제 #10
0
 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;
 }
예제 #11
0
파일: send_udp.cpp 프로젝트: rtobar/spead2
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)
{
}
예제 #12
0
    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;
    }
예제 #13
0
파일: udp.cpp 프로젝트: ijon/blackhole
    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());
    }
예제 #14
0
파일: lan.cpp 프로젝트: dsingleton/playdar
/// 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() );
}
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));
}
예제 #16
0
    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;
    }
예제 #17
0
파일: UDPClient.cpp 프로젝트: Bia10/clrn
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;
	}
}
예제 #18
0
파일: lan.cpp 프로젝트: dsingleton/playdar
void
lan::receive_pong(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 PONG dropped." << endl;
        return;
    }
    if(om.find("http_port")==om.end() || om["http_port"].type()!=int_type)
    {
        cout << "Malformed UDP PONG dropped." << endl;
        return;
    }
    string from_name = om["from_name"].get_str();
    cout << "Received UDP PONG 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;
    cout << "Current LAN roster: ";
    typedef std::pair<string,lannode> pair_t;
    BOOST_FOREACH( pair_t p, m_lannodes )
    {
        cout << p.first << ": " << p.second.lastdate << ", ";
    }
    cout << endl;
}
예제 #19
0
파일: lan.cpp 프로젝트: dsingleton/playdar
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);
}
예제 #20
0
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());
}
예제 #21
0
파일: udp_socket.cpp 프로젝트: DerKorb/fc
 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() );
 }
예제 #22
0
파일: EMServer.cpp 프로젝트: Fynx/EMeeting
std::string EMServer::get_address_from_endpoint(boost::asio::ip::udp::endpoint &endpoint) const
{
	return endpoint.address().to_string() + ":" + std::to_string(endpoint.port());
}
void refBoxTransport::handle_recv_error(boost::asio::ip::udp::endpoint &endpoint, std::string msg)
{
    printf("Receive error from %s:%u: %s\n",
	 endpoint.address().to_string().c_str(), endpoint.port(), msg.c_str());
}
예제 #24
0
bool udp_handler::on_async_receive_from(
    const boost::asio::ip::udp::endpoint & ep, const char * buf,
    const std::size_t & len
    )
{
    if (auto n = node_impl_.lock())
    {
        if (static_cast<std::uint8_t> (buf[0]) & protocol::message_flag_0x40)
        {
            if (
                static_cast<std::uint8_t> (buf[0]) &
                protocol::message_flag_encrypted
                )
            {
                /**
                 * Allocate the message.
                 */
                message msg(buf, len);
                
                /**
                 * Get the shared secret.
                 */
                auto shared_secret = n->get_key_pool()->find(ep);

                if (shared_secret.size() > 0 && msg.decrypt(shared_secret))
                {
                    on_data(ep, msg.data(), msg.size());
                }
                else
                {
                    protocol::header_t hdr;
                    
                    std::memcpy(&hdr, buf, sizeof(hdr));
       
                    hdr.transaction_id = ntohs(hdr.transaction_id);
                
                    log_debug(
                        "UDP handler, message " << hdr.transaction_id  <<
                        " decryption failed."
                    );
                    
                    /**
                     * Allocate the protocol::message_code_public_key_ping.
                     */
                    std::shared_ptr<message> request(
                        new message(protocol::message_code_public_key_ping)
                    );
                    
                    /**
                     * Add their public endpoint as a
                     * message::attribute_type_endpoint.
                     */
                    message::attribute_endpoint attr1;
                    
                    attr1.type = message::attribute_type_endpoint;
                    attr1.length = 0;
                    attr1.value = ep;
                    
                    request->endpoint_attributes().push_back(attr1);
                    
                    /**
                     * Add our public key as a message::attribute_string of
                     * type message::attribute_type_public_key.
                     */
                    message::attribute_string attr2;
                    
                    attr2.type = message::attribute_type_public_key;
                    attr2.length = n->get_ecdhe()->public_key().size();
                    attr2.value = n->get_ecdhe()->public_key();
                    
                    request->string_attributes().push_back(attr2);
                    
                    /**
                     * Send the request.
                     */
                    send_message(ep, request);

                    return false;
                }
            }
            else
            {
                on_data(ep, buf, len);
            }
        }
        else
        {
            n->on_app_udp_receive(
                ep.address().to_string().c_str(), ep.port(), buf, len
            );
        }
    }
    else
    {
        return false;
    }
    
    return true;
}
void MessageHandler::sendMessage(const DataMessage& msg, const boost::asio::ip::udp::endpoint& destination)
{
	debug<<"sending msg:"<<msg.getID()<<" to:"<<destination.address().to_string()<<std::endl;
	sendMessage(msg.getMsgAsProto(), destination);
}
예제 #26
0
파일: Endpoint.cpp 프로젝트: HymiR/i2pcpp
	Endpoint::Endpoint(boost::asio::ip::udp::endpoint const &ep) :
		m_addr(ep.address()),
		m_port(ep.port()) {}
예제 #27
0
void udp_multiplexor::send_to(
    const boost::asio::ip::udp::endpoint & ep, const char * buf,
    const std::size_t & len
    )
{
    m_bytes_sent += len;

    auto uptime = std::time(0) - send_time_;
    
    if (uptime > 0)
    {
        m_bps_sent = m_bytes_sent / uptime;
    
        log_none("m_bps_sent = " << m_bps_sent);
        
        if (uptime > 1)
        {
            send_time_ = std::time(0);
            
            uptime = std::time(0) - send_time_;
            
            m_bytes_sent = 0;
        }
    }
    
    if (ep.protocol() == boost::asio::ip::udp::v4())
    {
        if (socket_ipv4_.is_open())
        {
            boost::system::error_code ec;
            
            /**
             * Perform a blocking send_to.
             */
            socket_ipv4_.send_to(boost::asio::buffer(buf, len), ep, 0, ec);
            
            if (ec)
            {
                log_debug("UDP v4 send failed " << ec.message() << ".");
                
                if (ec == boost::asio::error::broken_pipe)
                {
                    std::uint16_t port = socket_ipv4_.local_endpoint().port();
                    
                    close();
                    
                    open(port);
                    
                    boost::system::error_code ignored_ec;
                    
                    /**
                     * Perform a blocking send_to.
                     */
                    socket_ipv4_.send_to(
                        boost::asio::buffer(buf, len), ep, 0, ignored_ec
                    );
                }
            }
        }
    }
    else
    {
        if (socket_ipv6_.is_open())
        {
            boost::system::error_code ec;
            
            /**
             * Perform a blocking send_to.
             */
            socket_ipv6_.send_to(boost::asio::buffer(buf, len), ep, 0, ec);

            if (ec)
            {
                log_debug("UDP v6 send failed " << ec.message() << ".");
                
                if (ec == boost::asio::error::broken_pipe)
                {
                    std::uint16_t port = socket_ipv6_.local_endpoint().port();
                    
                    close();
                    
                    open(port);
                    
                    boost::system::error_code ignored_ec;
                    
                    /**
                     * Perform a blocking send_to.
                     */
                    socket_ipv6_.send_to(
                        boost::asio::buffer(buf, len), ep, 0, ignored_ec
                    );
                }
            }
        }
    }
}
void
handle_recv_error(boost::asio::ip::udp::endpoint &endpoint, std::string msg)
{
  ROS_WARN("Receive error from %s:%u: %s",
           endpoint.address().to_string().c_str(), endpoint.port(), msg.c_str());
}
예제 #29
0
uint64_t kcp_client::endpoint_to_i(const boost::asio::ip::udp::endpoint& ep)
{
    uint64_t addr_i = ep.address().to_v4().to_ulong();
    uint32_t port = ep.port();
    return (addr_i << 32) + port;
}
예제 #30
0
void udp_multiplexor::send_to(
    const boost::asio::ip::udp::endpoint & ep, const char * buf,
    const std::size_t & len
    )
{
    /**
     * If the length cannot fit within the MTU of the underlying
     * datagram protocol we can perform fragmentation and IP-layer
     * fragmentation is allowed to the size of 2 Kilobytes.
     */
    if (len < 65535)
    {
        m_bytes_sent += len;

        auto uptime = std::time(0) - send_time_;
        
        if (uptime > 0)
        {
            m_bps_sent = m_bytes_sent / uptime;
        
            log_none("m_bps_sent = " << m_bps_sent);
            
            if (uptime > 1)
            {
                send_time_ = std::time(0);
                
                uptime = std::time(0) - send_time_;
                
                m_bytes_sent = 0;
            }
        }
        
        if (ep.protocol() == boost::asio::ip::udp::v4())
        {
            if (socket_ipv4_.is_open())
            {
                boost::system::error_code ec;
                
                /**
                 * Perform a blocking send_to.
                 */
                socket_ipv4_.send_to(boost::asio::buffer(buf, len), ep, 0, ec);
                
                if (ec)
                {
                    log_debug("UDP v4 send failed " << ec.message() << ".");
                    
                    if (ec == boost::asio::error::broken_pipe)
                    {
                        std::uint16_t port = socket_ipv4_.local_endpoint().port();
                        
                        close();
                        
                        open(port);
                        
                        boost::system::error_code ignored_ec;
                        
                        /**
                         * Perform a blocking send_to.
                         */
                        socket_ipv4_.send_to(
                            boost::asio::buffer(buf, len), ep, 0, ignored_ec
                        );
                    }
                }
            }
        }
        else
        {
            if (socket_ipv6_.is_open())
            {
                boost::system::error_code ec;
                
                /**
                 * Perform a blocking send_to.
                 */
                socket_ipv6_.send_to(boost::asio::buffer(buf, len), ep, 0, ec);

                if (ec)
                {
                    log_debug("UDP v6 send failed " << ec.message() << ".");
                    
                    if (ec == boost::asio::error::broken_pipe)
                    {
                        std::uint16_t port = socket_ipv6_.local_endpoint().port();
                        
                        close();
                        
                        open(port);
                        
                        boost::system::error_code ignored_ec;
                        
                        /**
                         * Perform a blocking send_to.
                         */
                        socket_ipv6_.send_to(
                            boost::asio::buffer(buf, len), ep, 0, ignored_ec
                        );
                    }
                }
            }
        }
    }
}