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


C++ IpAddress::getIpText方法代码示例

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


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

示例1: appendDropZones

//For every ECLWatchVisible dropzones, read: dropZoneName, directory, and, if available, computer.
//For every Servers/Server in ECLWatchVisible dropzones, read: directory,
// server name, and hostname(or IP). Create dropzone("@name", "@directory", "@computer",
// "@netAddress", "@linux", "@sourceNode") tree into pSoftware.
void CFileSpraySoapBindingEx::appendDropZones(double clientVersion, IConstEnvironment* env, const char* dfuwuidSourcePartIP, IPropertyTree* softwareTree)
{
    Owned<IConstDropZoneInfoIterator> dropZoneItr = env->getDropZoneIterator();
    ForEach(*dropZoneItr)
    {
        IConstDropZoneInfo& dropZoneInfo = dropZoneItr->query();
        if (!dropZoneInfo.isECLWatchVisible()) //This code is used by ECLWatch. So, skip the DZs not for ECLWatch.
            continue;

        SCMStringBuffer dropZoneName, directory, computerName;
        dropZoneInfo.getName(dropZoneName);
        dropZoneInfo.getDirectory(directory);
        if (!dropZoneName.length() || !directory.length())
            continue;

        bool isLinux = getPathSepChar(directory.str()) == '/' ? true : false;
        Owned<IConstDropZoneServerInfoIterator> dropZoneServerItr = dropZoneInfo.getServers();
        ForEach(*dropZoneServerItr)
        {
            IConstDropZoneServerInfo& dropZoneServer = dropZoneServerItr->query();

            StringBuffer name, server, networkAddress;
            dropZoneServer.getName(name);
            dropZoneServer.getServer(server);
            if (name.isEmpty() || server.isEmpty())
                continue;

            IPropertyTree* dropZone = softwareTree->addPropTree("DropZone", createPTree());
            dropZone->setProp("@name", dropZoneName.str());
            dropZone->setProp("@computer", name.str());
            dropZone->setProp("@directory", directory.str());
            if (isLinux)
                dropZone->setProp("@linux", "true");

            IpAddress ipAddr;
            ipAddr.ipset(server.str());
            ipAddr.getIpText(networkAddress);
            if (!ipAddr.isNull())
            {
                dropZone->addProp("@netAddress", networkAddress);

                if (!isEmptyString(dfuwuidSourcePartIP))
                {
                    IpAddress ip(dfuwuidSourcePartIP);
                    if (ip.ipequals(ipAddr))
                        dropZone->addProp("@sourceNode", "1");
                }
            }
        }
    }
}
开发者ID:richardkchapman,项目名称:HPCC-Platform,代码行数:55,代码来源:ws_fsBinding.cpp

示例2: run

    virtual int run()
    {
        Thread::Link();

        int ret = 0;
        try
        {
            char peername[256];
            int clientport = m_client->peer_name(peername, 256);

            char inbuf[1024];
            char outbuf[1024];
            memset(inbuf, 0, 1024);
            memset(outbuf, 0, 1024);

            unsigned int len = 0;
            unsigned int lenread = 0;
            m_client->read(inbuf, 8, 8, lenread);
            if(lenread != 8)
            {
                DBGLOG("didn't get the first 8 bytes, invalid socks request.");
                return -1;
            }

            len += lenread;
            m_client->read(inbuf + len, 0, 1, lenread);
            StringBuffer username;
            while(lenread > 0)
            {
                len += lenread;
                if(len >= 1023)
                {
                    len = 0;
                }
                if(inbuf[len - 1] == '\0')
                {
                    break;
                }
                char c = inbuf[len - 1];
                username.append(c);
                m_client->read(inbuf + len, 0, 1, lenread);
            }
            
            if(http_tracelevel >= 5)
                fprintf(m_ofile, "\n>>receivd SOCKS request from %s:%d, user %s\n", peername, clientport, username.str());

            outbuf[0] = '\0';
            outbuf[1] = (char)0x5a;

            m_client->write(outbuf, 8);

            char ubyte = inbuf[2];
            char lbyte = inbuf[3];
            unsigned short port = (unsigned short)ubyte;
            port = port << 8;
            port += lbyte;

            // TBD IPV6 (should use serialize/deserialize)

            IpAddress ip;
            ip.setNetAddress(4,inbuf+4);        
                                                

            StringBuffer ipstr;
            ip.getIpText(ipstr);
            if(http_tracelevel >= 5)
                fprintf(m_ofile, "\n>>The request is for %s:%d\n", ipstr.str(), port);      

            SocketEndpoint ep;
            ep.set(port, ip);
            m_remotesocket.setown(ISocket::connect(ep));

            m_client->set_nonblock(false);
            m_remotesocket->set_nonblock(false);
            CReadWriteThread t1(m_client.get(), m_remotesocket.get(), m_ofile);
            CReadWriteThread t2(m_remotesocket.get(), m_client.get(), m_ofile);
            t1.start();
            t2.start();
            t1.join();
            t2.join();
            m_remotesocket->shutdown();
            m_remotesocket->close();
            m_client->shutdown();
            m_client->close();
        }
        catch(IException *excpt)
        {
            StringBuffer errMsg;
            DBGLOG("%s", excpt->errorMessage(errMsg).str());
            ret = -1;
        }
        catch(...)
        {
            DBGLOG("unknown exception");
            ret = -1;
        }

        Thread::Release();

        return 0;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: ConvertAddress

void Cws_machineEx::ConvertAddress( const char* originalAddress, StringBuffer& newAddress)
{
    if (!originalAddress || !*originalAddress)
        throw MakeStringException(ECLWATCH_INVALID_IP_OR_COMPONENT, "No network address or computer name specified!");

    StringArray sArray;
    sArray.appendList(originalAddress, ":");

    if (sArray.ordinality() < 4)
        throw MakeStringException(ECLWATCH_MISSING_PARAMS, "Incomplete arguments");

    const char* address = sArray.item(0);
    const char* compType= sArray.item(1);
    const char* compName= sArray.item(2);
    const char* OS        = sArray.item(3);
    const char* path      = sArray.item(4);

    StringBuffer process;
    if (sArray.ordinality() > 5)
    {
        const char* ClusterType   = sArray.item(5);
        if (ClusterType && *ClusterType)
        {
            if (strcmp("THORMACHINES",ClusterType) == 0)
            {
                process.append("ThorMasterProcess");
            }
            else if (strcmp("ROXIEMACHINES",ClusterType) == 0)
            {
                process.append("RoxieServerProcess");
            }
        }
    }

    if (strchr(address, '.')) //have an IP address
    {
        newAddress.clear().append(originalAddress);
        return;
    }

    StringBuffer xpath;
    if (!strcmp(compType, "RoxieCluster"))
    {
        xpath.append("RoxieServer");
    }
    else if (!strcmp(compType, "ThorCluster"))
    {
        xpath.append("ThorMaster");
    }
    else if (!strcmp(compType, "HoleCluster"))
    {
        xpath.append("HoleControl");
    }
    else
        throw MakeStringException(ECLWATCH_INVALID_COMPONENT_TYPE, "Failed to resolve address for component type '%s'", compType);

    Owned<IPropertyTree> pComponent = getComponent(compType, address);
    xpath.append("Process[1]/@computer");
    const char* computer = pComponent->queryProp(xpath.str());

    if (!computer || !*computer)
        throw MakeStringException(ECLWATCH_INVALID_COMPONENT_INFO, "Failed to resolve computer for %s '%s'!", compType, address);

    Owned<IConstEnvironment> pConstEnv = getConstEnvironment();
    Owned<IConstMachineInfo> pConstMc  = pConstEnv->getMachine(computer);

    SCMStringBuffer sAddress;
    pConstMc->getNetAddress(sAddress);
#ifndef OLD_START_STOP
    {
        StringBuffer sConfigAddress;
        sConfigAddress.append(sAddress.str());

        if (!strcmp(sAddress.str(), "."))
        {
            StringBuffer ipStr;
            IpAddress ipaddr = queryHostIP();
            ipaddr.getIpText(ipStr);
            if (ipStr.length() > 0)
            {
#ifdef MACHINE_IP
                sAddress.set(MACHINE_IP);
#else
                sAddress.set(ipStr.str());
#endif
            }
        }

        if (process.length() > 0)
            newAddress.clear().appendf("%s|%s:%s:%s:%s:%s", sAddress.str(), sConfigAddress.str(), process.str(), compName, OS, path);
        else
            newAddress.clear().appendf("%s|%s:%s:%s:%s:%s", sAddress.str(), sConfigAddress.str(), compType, compName, OS, path);
    }
#else
        if (process.length() > 0)
            newAddress.clear().appendf("%s:%s:%s:%s:%s", sAddress.str(), process.str(), compName, OS, path);
        else
            newAddress.clear().appendf("%s:%s:%s:%s:%s", sAddress.str(), compType, compName, OS, path);
        //newAddress.clear().appendf("%s:ThorMasterProcess:%s:%s:%s", sAddress.str(), compName, OS, path);
#endif
//.........这里部分代码省略.........
开发者ID:RogerDev,项目名称:HPCC-Platform,代码行数:101,代码来源:ws_machineServiceRexec.cpp

示例4: doWork

   virtual void doWork()
   {
        if (m_useHPCCInit)
        {
            //address specified can be either IP or name of component
            const char* address = m_sAddress.str();
            const char* configAddress = m_sConfigAddress.str();
            if (!address || !*address)
                throw MakeStringException(ECLWATCH_INVALID_IP_OR_COMPONENT, "Invalid address or component name was specified!");

            if (!strchr(address, '.')) //not an IP address
            {
                const char* compType = m_pResult->getCompType();
                const char* compName = address;

                if (!compType || !*compType)
                    throw MakeStringException(ECLWATCH_INVALID_COMPONENT_TYPE, "No component type specified!");

                StringBuffer xpath;
                if (!strcmp(compType, "RoxieCluster"))
                {
                    xpath.append("RoxieServer");
                }
                else if (!strcmp(compType, "ThorCluster"))
                {
                    xpath.append("ThorMaster");
                }
                else if (!strcmp(compType, "HoleCluster"))
                {
                    xpath.append("HoleControl");
                }
                else
                    throw MakeStringException(ECLWATCH_INVALID_COMPONENT_TYPE, "Failed to resolve component type '%s'", compType);

                Owned<IPropertyTree> pComponent = m_pService->getComponent(compType, compName);
                xpath.append("Process[1]/@computer");
                const char* computer = pComponent->queryProp(xpath.str());

                if (!computer || !*computer)
                    throw MakeStringException(ECLWATCH_INVALID_COMPONENT_INFO, "Failed to resolve computer for %s '%s'!", compType, compName);

                Owned<IConstEnvironment> pConstEnv = m_pService->getConstEnvironment();
                Owned<IConstMachineInfo> pConstMc  = pConstEnv->getMachine(computer);

                SCMStringBuffer sAddress;
                pConstMc->getNetAddress(sAddress);

                if (!stricmp(m_sAddress.str(), m_sConfigAddress.str()))
                {
                    m_sAddress.clear().append(sAddress.str());
                    m_sConfigAddress = m_sAddress;
                    m_pResult->setAddress( sAddress.str() );
                }
                else
                {
                    m_sAddress.clear().append(sAddress.str());
                    m_pResult->setAddress( sAddress.str() );
                    if (configAddress && !strchr(configAddress, '.')) //not an IP address
                    {
                        Owned<IPropertyTree> pComponent = m_pService->getComponent(compType, configAddress);
                        xpath.append("Process[1]/@computer");
                        const char* computer = pComponent->queryProp(xpath.str());

                        if (!computer || !*computer)
                            throw MakeStringException(ECLWATCH_INVALID_COMPONENT_INFO, "Failed to resolve computer for %s '%s'!", compType, configAddress);

                        Owned<IConstEnvironment> pConstEnv = m_pService->getConstEnvironment();
                        Owned<IConstMachineInfo> pConstMc  = pConstEnv->getMachine(computer);

                        SCMStringBuffer sAddress;
                        pConstMc->getNetAddress(sAddress);
                        m_sConfigAddress.clear().append(sAddress.str());
                    }
                }
            }

            if ((m_sAddress.length() > 0) && !stricmp(m_sAddress.str(), "."))
            {
                StringBuffer ipStr;
                IpAddress ipaddr = queryHostIP();
                ipaddr.getIpText(ipStr);
                if (ipStr.length() > 0)
                {
#ifdef MACHINE_IP
                    m_sAddress.clear().append(MACHINE_IP);
#else
                    m_sAddress.clear().append(ipStr.str());
#endif
                    m_pResult->setAddress( m_sAddress.str() );
                }
            }

#ifdef OLD_START_STOP
            int OS = m_pResult->getOS();

            StringBuffer sPath( m_pResult->getPath() );
            if (OS == 0)
                sPath.replace('$', ':');
            else
                if (sPath.charAt(0) != '/')
//.........这里部分代码省略.........
开发者ID:RogerDev,项目名称:HPCC-Platform,代码行数:101,代码来源:ws_machineServiceRexec.cpp

示例5: createPTreeForXslt

IPropertyTree* CFileSpraySoapBindingEx::createPTreeForXslt(const char* method, const char* dfuwuid)
{
    Owned<IEnvironmentFactory> factory = getEnvironmentFactory();
    Owned<IConstEnvironment> m_constEnv = factory->openEnvironment();
    Owned<IPropertyTree> pEnvRoot = &m_constEnv->getPTree();
    IPropertyTree* pEnvSoftware = pEnvRoot->queryPropTree("Software");

    Owned<IPropertyTree> pRoot = createPTreeFromXMLString("<Environment/>");
    IPropertyTree* pSoftware = pRoot->addPropTree("Software", createPTree("Software"));

    if (pEnvSoftware)
    {
        StringBuffer dfuwuidSourcePartIP, wuxml;
        if(dfuwuid && *dfuwuid)
        {
            Owned<IDFUWorkUnitFactory> dfuwu_factory = getDFUWorkUnitFactory();
            Owned<IConstDFUWorkUnit> dfuwu = dfuwu_factory->openWorkUnit(dfuwuid, false);
            if(dfuwu)
            {   
                dfuwu->toXML(wuxml);

                Owned<IPropertyTree> wu = createPTreeFromXMLString(wuxml.str());
                if (wu)
                {
                    const char* ip = wu->queryProp("Source/Part/@node");
                    if (ip && *ip)
                        dfuwuidSourcePartIP.append(ip);
                }
            }
        }

        Owned<IPropertyTreeIterator> it = pEnvSoftware->getElements("DropZone");
        ForEach(*it)
        {
            IPropertyTree* pDropZone = pSoftware->addPropTree("DropZone", &it->get());
            //get IP Address of the computer associated with this drop zone
            const char* pszComputer = it->query().queryProp("@computer");
            if (!strcmp(pszComputer, "."))
                pszComputer = "localhost";

            StringBuffer xpath;
            xpath.appendf("Hardware/Computer[@name='%s']/@netAddress", pszComputer);

            StringBuffer sNetAddr;
            const char* pszNetAddr = pEnvRoot->queryProp(xpath.str());
            if (strcmp(pszNetAddr, "."))
            {       
                sNetAddr.append(pszNetAddr);
            }
            else
            {
                StringBuffer ipStr;
                IpAddress ipaddr = queryHostIP();
                ipaddr.getIpText(ipStr);
                if (ipStr.length() > 0)
                {
#ifdef MACHINE_IP
                    sNetAddr.append(MACHINE_IP);
#else
                    sNetAddr.append(ipStr.str());
#endif
                }
            }
            pDropZone->addProp("@netAddress", sNetAddr.str());
            if ((dfuwuidSourcePartIP.length() > 0) && (sNetAddr.length() > 0))
            {
                IpAddress ip1(dfuwuidSourcePartIP.str()), ip2(sNetAddr.str());
                if (ip1.ipequals(ip2))              
                    pDropZone->addProp("@sourceNode", "1");
            }

            Owned<IConstMachineInfo> machine;
            if (strcmp(pszNetAddr, "."))
                machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str()));
            else
            {
                machine.setown(m_constEnv->getMachineByAddress(pszNetAddr));
                if (!machine)
                    machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str()));
            }

            if (machine)
            {
                //int os = machine->getOS();
                StringBuffer dir;
                pDropZone->getProp("@directory", dir);
                if (machine->getOS() == MachineOsLinux || machine->getOS() == MachineOsSolaris)
                {         
                    dir.replace('\\', '/');//replace all '\\' by '/'
                    pDropZone->setProp("@linux", "true");
                }
                else
                {       
                    dir.replace('/', '\\');
                    dir.replace('$', ':');
                }
                pDropZone->setProp("@directory", dir);
            }
        }

//.........这里部分代码省略.........
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:101,代码来源:ws_fsBinding.cpp


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