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


C++ HostAddress::getAddressType方法代码示例

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


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

示例1: _parseLocator

PEGASUS_NAMESPACE_BEGIN

static bool _parseLocator(
    const String &locator,
    HostAddress& addr,
    Uint32& port)
{
    const Uint16* first = (const Uint16*)locator.getChar16Data();
    const Uint16* last = first + locator.size();

    port = HostLocator::PORT_UNSPECIFIED;

    // Reject zero length locators.

    if (first == last)
    {
        return false;
    }

    // Parse the host address.

    const Uint16* p = first;

    if (*p == '[')
    {
        // Parse "[...]" expresion.

        const Uint16* start = ++p;

        while (*p && *p != ']')
            p++;

        if (*p != ']')
        {
            return false;
        }

        addr.setHostAddress(String((const Char16*)start, p - start));
        p++;

        // Only IPV6 addresses may be enclosed in braces.

        if (addr.getAddressType() != HostAddress::AT_IPV6)
        {
            return false;
        }
    }
    else
    {
        // Find end-of-string host address (null terminator or colon).

        const Uint16* start = p;

        while (*p && *p != ':')
            p++;

        addr.setHostAddress(String((const Char16*)start, p - start));

        if (!addr.isValid())
        {
            return false;
        }

        // IPV6 addresses must be enclosed in braces.

        if (addr.getAddressType() == HostAddress::AT_IPV6)
        {
            return false;
        }
    }

    // Parse the port number:

    if (*p == ':')
    {
        const Uint16* start = ++p;

        // If empty port number, ignore and proceed as unspecified port.
        if (start == last)
        {
            return true;
        }

        port = HostLocator::PORT_INVALID;

        // Convert string port number to integer (start at end of string).

        Uint32 r = 1;
        Uint32 x = 0;

        for (const Uint16* q = last; q != start; q--)
        {
            Uint16 c = q[-1];

            if (c > 127 || !isdigit(c))
                return false;

            x += r * (c - '0');
            r *= 10;
        }
//.........这里部分代码省略.........
开发者ID:brunolauze,项目名称:pegasus,代码行数:101,代码来源:HostLocator.cpp

示例2: _connect

void ExportClient::_connect()
{
    PEG_METHOD_ENTER (TRC_EXPORT_CLIENT,"ExportClient::_connect()");
 
    if(!isWSMANExportIndication)
    {
        // Create response decoder:

        _cimResponseDecoder = new CIMExportResponseDecoder(
            this,
            _cimRequestEncoder,
            &_authenticator);
        
        // Attempt to establish a connection:

        try
        { 
            _httpConnection = _httpConnector->connect(_connectHost,
                _connectPortNumber,
                _connectSSLContext.get(),
                _timeoutMilliseconds,
                _cimResponseDecoder);
        }
        catch (...)
        {
            // Some possible exceptions are CannotCreateSocketException,
            // CannotConnectException, and InvalidLocatorException
            delete _cimResponseDecoder;
            PEG_METHOD_EXIT();
            throw;
        }

    }
    else
    {
#ifdef PEGASUS_ENABLE_PROTOCOL_WSMAN
        // Create response decoder:
        _wsmanResponseDecoder =  new WSMANExportResponseDecoder(
            this,
            _wsmanRequestEncoder,
            &_authenticator);
        
        // Attempt to establish a connection:
        try
        {
           
            _httpConnection = _httpConnector->connect(_connectHost,
                _connectPortNumber,
                _connectSSLContext.get(),
                _timeoutMilliseconds,
                _wsmanResponseDecoder);
        }
        catch(...)
        {
            // Some possible exceptions are CannotCreateSocketException,
            // CannotConnectException, and InvalidLocatorException
            delete _wsmanResponseDecoder;
            PEG_METHOD_EXIT();
            throw;

        }
#endif
    }

    String connectHost = _connectHost;

#ifdef PEGASUS_ENABLE_IPV6
    HostAddress hst;
    hst.setHostAddress(connectHost);
    if (hst.getAddressType() == HostAddress::AT_IPV6)
    {
        connectHost = "[" + connectHost + "]";
    }
#endif

    char portStr[32];
    if (connectHost.size())
    {
        sprintf(portStr, ":%u", _connectPortNumber);
        connectHost.append(portStr);
    }

#ifdef PEGASUS_ENABLE_PROTOCOL_WSMAN
    //Create requestEncoder to encode the exportIndication request.
    if(isWSMANExportIndication)
    {
        _wsmanRequestEncoder= new WSMANExportRequestEncoder(
            _httpConnection,
            _connectHost,
            portStr,
            &_authenticator);
        _wsmanResponseDecoder->setEncoderQueue(_wsmanRequestEncoder); 
    }
    else
#endif
    {
        _cimRequestEncoder = new CIMExportRequestEncoder(
            _httpConnection,
            connectHost,
            &_authenticator);
//.........这里部分代码省略.........
开发者ID:brunolauze,项目名称:pegasus,代码行数:101,代码来源:ExportClient.cpp


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