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


C++ HostAddress类代码示例

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


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

示例1: noteHostBad

void HostCatcher::noteHostBad( HostAddress * inHost ) {
    mLock->lock();
    
    // make sure this host already exists in our list
    char exists = false;

    HostAddress *foundHost = NULL;
    
    int numHosts = mHostVector->size();

    for( int i=0; i<numHosts; i++ ) {
        HostAddress *otherHost =  *( mHostVector->getElement( i ) );

        if( otherHost->equals( inHost ) ) {
            exists = true;

            // delete the host that we've found
            mHostVector->deleteElement( i );

            foundHost = otherHost;
            
            // jump out of loop
            i = numHosts;
            }
        }

    
    if( exists ) {
        delete foundHost;
        //mHostVector->push_back( foundHost );
        }

    mLock->unlock();
    }
开发者ID:MrPhil,项目名称:CastleDoctrine,代码行数:34,代码来源:HostCatcher.cpp

示例2:

HostAddress * HostCatcher::getHost(  ) {

    mLock->lock();
    
    int numHosts = mHostVector->size();

    if( numHosts == 0 ) {
        mLock->unlock();
        return NULL;
        }

    // remove random host from queue
    int index = mRandSource->getRandomBoundedInt( 0, numHosts - 1 ); 
    HostAddress *host = *( mHostVector->getElement( index ) );
    mHostVector->deleteElement( index );

    // add host to end of queue
    mHostVector->push_back( host );

    HostAddress *hostCopy = host->copy();

    
    mLock->unlock();
    
    return hostCopy;   
    }
开发者ID:MrPhil,项目名称:CastleDoctrine,代码行数:26,代码来源:HostCatcher.cpp

示例3: isListenAddressValid

static Boolean isListenAddressValid(const String value_)
{
    if(value_.size() == 0 )
    {
        return false;
    }

    Boolean isIpListTrue = true;
    Array<String> interfaces = DefaultPropertyOwner::parseAndGetListenAddress(
                                   value_);

    HostAddress theAddress;
    for(Uint32 i = 0, m = interfaces.size(); i < m; ++i)
    {
        if(!theAddress.setHostAddress(interfaces[i]))
        {
            isIpListTrue = false;
            throw InvalidListenAddressPropertyValue(
                "listenAddress", interfaces[i]);
            break;
        }
    }

    return isIpListTrue;
}
开发者ID:deleisha,项目名称:neopegasus,代码行数:25,代码来源:DefaultPropertyOwner.cpp

示例4: gethostname

HostAddress *HostAddress::getLocalAddress() {
	int bufferLength = 200;
	char *buffer = new char[ bufferLength ];

	gethostname( buffer, bufferLength );

    
    char *name = stringDuplicate( buffer );

	delete [] buffer;


    // this class will destroy name for us
    HostAddress *nameAddress = new HostAddress( name, 0 );

    HostAddress *fullAddress = nameAddress->getNumericalAddress();

    if( fullAddress != NULL ) {
    
        delete nameAddress;

        return fullAddress;
        }
    else {
        return nameAddress;
        }
    
    }
开发者ID:vinay,项目名称:Transcend,代码行数:28,代码来源:HostAddressLinux.cpp

示例5: handleSystemCmdMsg

void TUIServerApp::handleSystemCmdMsg(HostEvent * msg) {
    HostAddress address = msg->getAddress();
    SystemCmdMsg * msg2 = static_cast<SystemCmdMsg *>(msg->getPayload());
    const SystemCmd & systemCmd = msg2->getPayload();
    address.setPortNr(systemCmd.getPortNr());
    if (systemCmd.getCmd() == SystemCmd::requestConnection) {
        TFDEBUG("SystemCmdMsg::RequestConnection: " << address);
        this->outHostMsgDispatcher.addDstAddress(address);
        if (this->usingMulticast) {
            MulticastGroupInvitationMsg * event = new MulticastGroupInvitationMsg();
            event->setPayload(this->multicastGroup);
            this->outEventQueue.push(event);
        } 

        {
            {
                GUIDEventTypeIDVectorMsg * event = new GUIDEventTypeIDVectorMsg();
                event->setPayload(this->guidEventTypeIDVector);
                this->outEventQueue.push(event);
            }
            {
                AttachedObjectsMsg * event = new AttachedObjectsMsg();
                event->setPayload(this->attachedObjects);
                this->outEventQueue.push(event);
            }

        }
    } else if (systemCmd.getCmd() == SystemCmd::removeConnection) {
        TFDEBUG("SystemCmdMsg::RemoveConnection: " << address);
        this->outHostMsgDispatcher.removeDstAddress(address);
    }
}
开发者ID:lkulf,项目名称:tuiframework,代码行数:32,代码来源:TUIServerApp.cpp

示例6: fromString

HostAddress HostAddress::fromString(std::string str) {
  HostAddress h;
  h.address_str = str;
  h.parse_string();
  h.initialised = true;
  return h;
}
开发者ID:matthieumorel,项目名称:bookkeeper,代码行数:7,代码来源:util.cpp

示例7: getSectionByAddr

Byte BinaryImage::readNative1(Address addr) const
{
    const BinarySection *section = getSectionByAddr(addr);

    if (section == nullptr || section->getHostAddr() == HostAddress::INVALID) {
        LOG_WARN("Invalid read at address %1: Address is not mapped to a section", addr);
        return 0xFF;
    }

    HostAddress host = section->getHostAddr() - section->getSourceAddr() + addr;
    return *reinterpret_cast<Byte *>(host.value());
}
开发者ID:nemerle,项目名称:boomerang,代码行数:12,代码来源:BinaryImage.cpp

示例8: while

void HostCatcher::addHost( HostAddress * inHost ) {
    

    // convert to numerical form once and for all here
    // (to avoid converting over and over in equals checks below)
    HostAddress *numericalAddress = inHost->getNumericalAddress();

    if( numericalAddress != NULL ) {

        mLock->lock();
        
        // make sure this host doesn't already exist in our list
        char exists = false;
    
        int numHosts = mHostVector->size();
    
        for( int i=0; i<numHosts; i++ ) {
            HostAddress *otherHost =  *( mHostVector->getElement( i ) );

            if( otherHost->equals( numericalAddress ) ) {
                exists = true;
                // jump out of loop
                i = numHosts;
                }
            }
    
    
    
        if( !exists ) {
            mHostVector->push_back( numericalAddress->copy() );
            }
        
    
        while( mHostVector->size() > mMaxListSize ) {
            // remove first host from queue
            HostAddress *host = *( mHostVector->getElement( 0 ) );
            mHostVector->deleteElement( 0 );
            delete host;
            }
    
        mLock->unlock();

        delete numericalAddress;
        }
    }
开发者ID:MrPhil,项目名称:CastleDoctrine,代码行数:45,代码来源:HostCatcher.cpp

示例9: Connection

    Connection(ProactorFile *socket, const HostAddress &addr): 
        mSrcSocket(socket), mDestSocket(nullptr), mRespForwardedPos(0), mCountOfEOF(0) {

        mID = format("Connection(%d,%s)", socket->getFd(), addr.toString().c_str());

        LOG("Connection(%s) established ...", getID());

        mSrcSocket->readLine('\n', [this](bool eof, const char *buf, int n){ onReadRequestline(eof, buf, n); });
    }
开发者ID:GHScan,项目名称:DailyProjects,代码行数:9,代码来源:main.cpp

示例10: memset

bool Network::UdpSocket::bind(const HostAddress& address, uint16 port) {
  struct sockaddr_in addr;
  
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = address.toIPv4Address();
  addr.sin_port = htons(port);
  if (::bind(_fd, (struct sockaddr*)&addr, sizeof(addr)) == -1)
    return (false);
  return (true);
}
开发者ID:jstoja,项目名称:r-type,代码行数:11,代码来源:UdpSocket.cpp

示例11: ConnectToHost

bool TcpSocket::ConnectToHost(const string& hostName,
                              const string& port,
                              IBamIODevice::OpenMode mode)
{
    // create new address object with requested host name
    HostAddress hostAddress;
    hostAddress.SetAddress(hostName);

    HostInfo info;
    // if host name was IP address ("x.x.x.x" or IPv6 format)
    // otherwise host name was 'plain-text' ("www.foo.bar")
    // we need to look up IP address(es)
    if ( hostAddress.HasIPAddress() )
        info.SetAddresses( vector<HostAddress>(1, hostAddress) );
    else
        info = HostInfo::Lookup(hostName, port);

    // attempt connection on requested port
    return ConnectImpl(info, port, mode);
}
开发者ID:AMoreau1,项目名称:haploclique,代码行数:20,代码来源:TcpSocket_p.cpp

示例12: printf

HostAddress *HostAddress::getLocalAddress() {
	
    // first make sure sockets are initialized
    if( !Socket::isFrameworkInitialized() ) {
		
		// try to init the framework
		
		int error = Socket::initSocketFramework();
		
		if( error == -1 ) {
			
			printf( "initializing network socket framework failed\n" );
			return NULL;
			}
		}
	
	
	
	
	int bufferLength = 200;
	char *buffer = new char[ bufferLength ];

	gethostname( buffer, bufferLength );

    char *name = stringDuplicate( buffer );

	delete [] buffer;


    // this class will destroy name for us
    HostAddress *nameAddress = new HostAddress( name, 0 );

    HostAddress *fullAddress = nameAddress->getNumericalAddress();

    delete nameAddress;

    
    return fullAddress;    
	}
开发者ID:MrPhil,项目名称:CastleDoctrine,代码行数:39,代码来源:HostAddressWin32.cpp

示例13: receiver

/*---------------------------------------------------------------------*/
void receiver(Socket* socket)
{	HostAddress peer;
	TextMessage msg(1024);

	try
	{
		do
		{
			socket->Receive(peer, msg);
			printf("[%s] msg=%s", peer.GetHost(), msg.GetBuffer());
		}
		while ( strcmp(msg.GetBuffer(), "bye\n") != 0 );
	}
	catch (Exception& err)
	{
		printf("[CHILD]");
		err.PrintException();
	}
	catch (...)
	{
		fprintf(stderr, "Unknown error\n");
	}
	exit(0);
}
开发者ID:rahulnij,项目名称:cprograms,代码行数:25,代码来源:broadcast-peer.cpp

示例14: address

bool RedisProxy::run(const HostAddress& addr)
{
    if (isRunning()) {
        return false;
    }

    if (m_vipEnabled) {
        TcpSocket sock = TcpSocket::createTcpSocket();
        Logger::log(Logger::Message, "connect to vip address(%s:%d)...", m_vipAddress, addr.port());
        if (!sock.connect(HostAddress(m_vipAddress, addr.port()))) {
            Logger::log(Logger::Message, "set VIP [%s,%s]...", m_vipName, m_vipAddress);
            int ret = NonPortable::setVipAddress(m_vipName, m_vipAddress, 0);
            Logger::log(Logger::Message, "set_vip_address return %d", ret);
        } else {
            m_vipSocket = sock;
            m_vipEvent.set(eventLoop(), sock.socket(), EV_READ, vipHandler, this);
            m_vipEvent.active();
        }
    }


    m_monitor->proxyStarted(this);
    Logger::log(Logger::Message, "Start the %s on port %d", APP_NAME, addr.port());

    RedisCommand cmds[] = {
        {"HASHMAPPING", 11, -1, onHashMapping, NULL},
        {"ADDKEYMAPPING", 13, -1, onAddKeyMapping, NULL},
        {"DELKEYMAPPING", 13, -1, onDelKeyMapping, NULL},
        {"SHOWMAPPING", 11, -1, onShowMapping, NULL},
        {"POOLINFO", 8, -1, onPoolInfo, NULL},
        {"SHUTDOWN", 8, -1, onShutDown, this}
    };
    RedisCommandTable::instance()->registerCommand(cmds, sizeof(cmds)/sizeof(RedisCommand));

    return TcpServer::run(addr);
}
开发者ID:DataNuts,项目名称:onecache,代码行数:36,代码来源:redisproxy.cpp

示例15: testToString_Invalid

        void testToString_Invalid() {
            HostAddress testling;

            CPPUNIT_ASSERT_EQUAL(std::string("0.0.0.0"), testling.toString());
        }
开发者ID:swift,项目名称:swift,代码行数:5,代码来源:HostAddressTest.cpp


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