当前位置: 首页>>代码示例>>C++>>正文


C++ Address::IsBroadcast方法代码示例

本文整理汇总了C++中Address::IsBroadcast方法的典型用法代码示例。如果您正苦于以下问题:C++ Address::IsBroadcast方法的具体用法?C++ Address::IsBroadcast怎么用?C++ Address::IsBroadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Address的用法示例。


在下文中一共展示了Address::IsBroadcast方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddConnection

////////////////////////////////////////////////////////////////////////////////////
///
///   \brief Method to add a new connection manually to a component at an
///          IP address.
///
///   \param[in] networkIP IP Address of component.
///   \param[in] jausID JAUS ID of component.
///   \param[in] port Network port to use (default is 3794).
///
///   \return True on success, false on failure.
///
////////////////////////////////////////////////////////////////////////////////////
bool JUDP::AddConnection(const CxUtils::IP4Address& networkIP,
                         const Address& jausID,
                         const unsigned short port)
{
    bool result = false;

    if(jausID.IsValid() && !jausID.IsBroadcast())
    {
        Mutex::ScopedLock lock(&mClientsMutex);
        std::map<Address, CxUtils::UdpClient*>::iterator citer;
        citer = mClients.find(jausID);
        if(citer == mClients.end())
        {
            CxUtils::UdpClient* udp = mMulticast.CreateNewDestination(networkIP, port);
            if(udp)
            {
                mClients[jausID] = udp;
                mUpdateTimes[jausID] = Time::GetUtcTimeMs();
                mPermanentConnections[jausID] = true;
                udp = NULL;
                result = true;
            }
            else
            {
                if(mDebugMessagesFlag)
                {
                    Mutex::ScopedLock lock(&mDebugMessagesMutex);
                    std::cout << "[" << GetServiceID().ToString() << "-" << mComponentID.ToString() << "] - New Connection Made to " << jausID << " at IP:" << networkIP.mString << std::endl;
                }
            }
        }
    }

    return result;
}
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:47,代码来源:judp.cpp

示例2: SetControllerID

////////////////////////////////////////////////////////////////////////////////////
///
///   \return ID of the controlling component.
///
////////////////////////////////////////////////////////////////////////////////////
void AccessControl::SetControllerID(const Address& id)
{
    if(id.IsValid() && !id.IsBroadcast())
    {
        Mutex::ScopedLock lock(&mControlMutex);
        mControllerID = id;
    }
}
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:13,代码来源:accesscontrol.cpp

示例3: SetControllerID

////////////////////////////////////////////////////////////////////////////////////
///
///   \brief Set the ID of controlling component.
///
///   \param[in] ID of the controlling component.
///
////////////////////////////////////////////////////////////////////////////////////
void AccessControl::SetControllerID(const Address& id)
{
    if(id.IsValid() && !id.IsBroadcast())
    {
        WriteLock wLock(mControlMutex);
        mControllerID = id;
    }
}
开发者ID:jarekAIM,项目名称:IGVC2015,代码行数:15,代码来源:AccessControl.cpp

示例4: SetSourceID

////////////////////////////////////////////////////////////////////////////////////
///
///   \brief Sets the source ID of the message.
///
///   \param[in] src Source ID.  Must be valid and non-broadcast.
///
///   \return OK on success, FAILURE on error.
///
////////////////////////////////////////////////////////////////////////////////////
int Message::SetSourceID(const Address& src)
{
    if(src.IsValid() && !src.IsBroadcast())
    {
        mSourceID = src;
        return OK;
    }
    return FAILURE;
}
开发者ID:jarekAIM,项目名称:IGVC2015,代码行数:18,代码来源:Message.cpp

示例5: Initialize

////////////////////////////////////////////////////////////////////////////////////
///
///   \brief Initializes the Transport Service based on configuration values
///          set.
///
///   \param[in] componentID ID of the component using the Transport Service.
///
///   \return True on success, false on failure.
///
////////////////////////////////////////////////////////////////////////////////////
bool JUDP::Initialize(const Address& componentID)
{
    if(componentID.IsValid() == false || componentID.IsBroadcast())
    {
        return false;
    }
    
    Shutdown();
    
    // Save ID.
    mComponentID = componentID;
    CxUtils::IP4Address::List hostnames;
    CxUtils::IP4Address::List::iterator eth0;
    CxUtils::Socket::GetHostAddresses(hostnames);
    if(hostnames.size() == 0 && mDebugMessagesFlag)
    {
        Mutex::ScopedLock lock(&mDebugMessagesMutex);
        std::cout << "[JUDP-" << mComponentID.ToString() << "] - No Network Interface Found.\n";
    }
    unsigned int count = 0;
    for(eth0 = hostnames.begin();
        eth0 != hostnames.end();
        eth0++, count++)
    {
        // Use any or specified interface.
        if(mHostIP.mString == "0.0.0.0" ||
           mHostIP.mString == "127.0.0.1" ||
           mHostIP.mString.empty() ||
           mHostIP == *eth0)
        {
            // Initialize UDP receiving.
            if(mInput.InitializeMulticastSocket(Port, mMulticastIP, true))
            {
                mMulticast.SetNetworkInterface(*eth0);
                if(mMulticast.InitializeMulticastSocket(mMulticastIP, Port, mTimeToLive, mUseBroadcastingFlag, 0))
                {
                    SetComponentID(componentID);
                    
                    mPrimaryThread.CreateThread(JUDP::ReceiveThread, this);
                    CxUtils::SleepMs(250);
                    mSecondaryThread.CreateThread(JUDP::ReceiveThread, this);
                    // Set thread names.
                    mPrimaryThread.SetThreadName(std::string("JUDP 1 ") + componentID.ToString());
                    mSecondaryThread.SetThreadName(std::string("JUDP 2 ") + componentID.ToString());
                    return true;
                }
            }
            /*
            mPrimarySocket.SetNetworkInterface(mHostIP);
            mSecondarySocket.SetNetworkInterface(mHostIP);
            // Try initialize on 3794 first, but accept any available.
            if(mPrimarySocket.InitializeMulticastSocket(mMulticastIP, Port, mTimeToLive, mUseBroadcastingFlag, Port, true) &&
               mSecondarySocket.InitializeMulticastSocket(mMulticastIP, Port, mTimeToLive, mUseBroadcastingFlag, 0, false))
            {
                    SetComponentID(componentID);
                    mPrimaryThread.CreateThread(JUDP::PrimaryThread, this);
                    std::string threadName = std::string("JUDP 1 ") + componentID.ToString();
                    mPrimaryThread.SetThreadName(threadName);

                    // Have a thread to discover new UDP clients that are transmitting.
                    mSecondaryThread.CreateThread(JUDP::SecondaryThread, this);
                    threadName = std::string("JUDP 2 ") + componentID.ToString();
                    mSecondaryThread.SetThreadName(threadName);

                    return true;
            }
            */
        }
    }
    
    Shutdown();

    return false;
}
开发者ID:ShowLove,项目名称:Robotics_Club,代码行数:84,代码来源:judp.cpp


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