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


C++ Endpoint类代码示例

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


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

示例1: Init

bool ReplicatedConfig::Init()
{
	Endpoint	endpoint;

	nodeID = Config::GetIntValue("paxos.nodeID", 0);
	numNodes = Config::GetListNum("paxos.endpoints");
	
	if (numNodes == 0)
	{
		endpoint.Set("0.0.0.0:10000");
		endpoints[0] = endpoint;
		nodeID = 0;
	}
	else
	{
		if (nodeID < 0 || nodeID >= numNodes)
			STOP_FAIL("Configuration error, "
					   "check your paxos.nodeID and paxos.endpoints entry" ,0);

		for (unsigned i = 0; i < numNodes; i++)
		{
			endpoint.Set(Config::GetListValue("paxos.endpoints", i, NULL), true);
			endpoints[i] = endpoint;
		}
	}
	
	if (strcmp("replicated", Config::GetValue("mode", "")) == 0)
		InitRestartCounter();
	
	return true;
}
开发者ID:KingJiangNet,项目名称:NPaxosLease,代码行数:31,代码来源:ReplicatedConfig.cpp

示例2: Error

int MediaSession::AudioMixerPortAttachToEndpoint(int mixerId,int portId,int endpointId)
{
	//Get mixer
        AudioMixers::iterator it = audioMixers.find(mixerId);

        //If not found
        if (it==audioMixers.end())
                //Exit
                return Error("AudioMixerResource not found\n");
        //Get it
        AudioMixerResource* audioMixer = it->second;

	//Get endpoint
        Endpoints::iterator itEnd = endpoints.find(endpointId);

        //If not found
        if (itEnd==endpoints.end())
                //Exit
                return Error("Endpoint not found\n");

        //Get it
        Endpoint* endpoint = itEnd->second;

	//Log endpoint tag name
	Log("-AudioMixerPortAttachToEndpoint [%ls]\n",endpoint->GetName().c_str());

	//Attach
	return audioMixer->Attach(portId,endpoint->GetJoinable(MediaFrame::Audio));
}
开发者ID:crubia,项目名称:wt,代码行数:29,代码来源:MediaSession.cpp

示例3: peer

void SaslConnection::close()
{
    Endpoint client = peer();
    Connection::close();

    if ( !u || logged ||
         !client.valid() || client.protocol() == Endpoint::Unix )
        return;

    logged = true;

    Query * q = new Query(
        "insert into connections "
        "(username,address,port,mechanism,authfailures,"
        "syntaxerrors,started_at,ended_at,userid) "
        "values ($1,$2,$3,$4,$5,$6,"
        "$7::interval + 'epoch'::timestamptz,"
        "$8::interval + 'epoch'::timestamptz,$9)", 0
    );

    q->bind( 1, u->login() );
    q->bind( 2, client.address() );
    q->bind( 3, client.port() );
    q->bind( 4, m );
    q->bind( 5, af );
    q->bind( 6, sf );
    q->bind( 7, s );
    q->bind( 8, (uint)time( 0 ) );
    q->bind( 9, u->id() );
    q->execute();

}
开发者ID:aox,项目名称:aox,代码行数:32,代码来源:saslconnection.cpp

示例4: NMAcceptConnection

NMErr
NMAcceptConnection(
    NMEndpointRef				inEndpoint,
    void						*inCookie,
    NMEndpointCallbackFunction	*inCallback,
    void						*inContext)
{
    DEBUG_ENTRY_EXIT("NMAcceptConnection");

    NMErr				status = kNMNoError;
    NMIPEndpointPriv	*epRef;
    Endpoint			*ep;
    NMIPEndpointPriv	*newEPRef;

    op_vassert_return((inEndpoint != NULL),"Endpoint is NIL!",kNMParameterErr);
    op_vassert_return((inCookie != NULL),"Cookie is NIL!",kNMParameterErr);
    op_vassert_return((inCallback != NULL),"Callback function is NIL!",kNMParameterErr);

    epRef = (NMIPEndpointPriv *) inEndpoint;
    ep = epRef->ep;

    op_vassert_return((ep != NULL),"Private endpoint is NIL!",kNMParameterErr);
    op_vassert_return((epRef->id == kModuleID),"Endpoint id is not mine!",kNMParameterErr);

    // First, we need to create a new endpoint that will be returned to the user
    status = MakeNewIPEndpointPriv(NULL, inCallback, inContext, ep->mMode, ep->mNetSprocketMode, &newEPRef);

    if( !status )
        status = ep->AcceptConnection(newEPRef->ep, inCookie);	// Hands off the new connection async

    return (status);
}
开发者ID:mctully,项目名称:tntbasic,代码行数:32,代码来源:NetModuleIP.cpp

示例5: NMReceive

NMErr
NMReceive(
    NMEndpointRef	inEndpoint,
    void			*ioData,
    NMUInt32			*ioSize,
    NMFlags			*outFlags)
{
    DEBUG_ENTRY_EXIT("NMReceive");

    NMErr				status = kNMNoError;
    NMIPEndpointPriv	*epRef;
    Endpoint 			*ep;

    op_vassert_return((inEndpoint != NULL),"Endpoint is NIL!",kNMParameterErr);
    op_vassert_return((ioData != NULL),"Data pointer is NULL!",kNMParameterErr);
    op_vassert_return((ioSize != NULL),"Data size pointer is NULL!",kNMParameterErr);
    op_vassert_return((outFlags != NULL),"Flags pointer is NULL!",kNMParameterErr);
    op_vassert_return((*ioSize >= 1),"Data size < 1!",kNMParameterErr);

    epRef = (NMIPEndpointPriv *) inEndpoint;
    ep = epRef->ep;

    op_vassert_return((ep != NULL),"Private endpoint is NIL!",kNMParameterErr);
    op_vassert_return((epRef->id == kModuleID),"Endpoint id is not mine!",kNMParameterErr);

    status = ep->Receive(ioData, ioSize, outFlags);
    return (status);
}
开发者ID:mctully,项目名称:tntbasic,代码行数:28,代码来源:NetModuleIP.cpp

示例6: main

int main()
{
    int ret = 0;
    Endpoint ep;

    try {
	ep.libCreate();

	mainProg3(ep);
	ret = PJ_SUCCESS;
    } catch (Error & err) {
	std::cout << "Exception: " << err.info() << std::endl;
	ret = 1;
    }

    try {
	ep.libDestroy();
    } catch(Error &err) {
	std::cout << "Exception: " << err.info() << std::endl;
	ret = 1;
    }

    if (ret == PJ_SUCCESS) {
	std::cout << "Success" << std::endl;
    } else {
	std::cout << "Error Found" << std::endl;
    }

    return ret;
}
开发者ID:Zion-007,项目名称:pjproject,代码行数:30,代码来源:pjsua2_demo.cpp

示例7: connect

int Connection::connect( const Endpoint &e )
{
    if ( !e.valid() )
        return -1;

    if ( !valid() ) {
        init( socket( e.protocol() ) );
        if ( !valid() )
            return -1;
    }

    int n = ::connect( d->fd, e.sockaddr(), e.sockaddrSize() );

    d->pending = false;
    setState( Connecting );
    if ( n == 0 || ( n < 0 && errno == EINPROGRESS ) ) {
        if ( n == 0 ) {
            d->event = Connect;
            d->pending = true;
        }
        n = 1;
    }
    else {
        d->event = Error;
        d->pending = true;
        n = -1;
    }

    return n;
}
开发者ID:netconstructor,项目名称:aox,代码行数:30,代码来源:connection.cpp

示例8: MW_LOG_DEBUG_TRACE

Network::msg_l3_status_t BaseRFApplication::sendPropertyReport(univmsg_l7_any_t* msg, bool cmd_mc_last,
		uint8_t clusterID, uint8_t endpointID) {
	MW_LOG_DEBUG_TRACE(MW_LOG_BASERF);

	//6.a.1) GET: create empty endpoint_value_t and call getProperty
	Endpoint::endpoint_value_t value;
	value.len = BASERF_MESSAGE_PAYLOAD_MAXLEN - BASERF_MESSAGE_PAYLOAD_HEADERLEN - 2;//12
	uint8_t maxLen = value.len;//12
	value.pvalue = &msg->data[2];//reusing the allocated buffer with a proper offset
	Endpoint* endpoint = m_device->getCluster(clusterID)->getEndpoint(endpointID);
	endpoint->getProperty(&value);

	int result = ERROR_INVALID_DATA;

	MW_LOG_DEBUG_TRACE(MW_LOG_BASERF) << PSTR("Endpoint value len: ") << value.len;
	if ( value.len > 0 && value.len <= maxLen ) {
		//prepare the message structure
		msg->msg_header.cmd_id = BASERF_CMD_PROPERTY_REP;
		msg->msg_header.cmd_mc = cmd_mc_last ? false : true;
		msg->msg_header.dataLen = value.len + 2;//extra bytes in the header

		msg->data[0] = clusterID;
		msg->data[1] = endpointID;

		result = sendMessage(msg);
	} else {
		MW_LOG_WARNING(MW_LOG_BASERF, "No report sent! Invalid data for C:E=%d:%d", clusterID, endpointID);
	}
	MW_LOG_DEBUG_TRACE(MW_LOG_BASERF) << PSTR("result=") << result;
	return result;
}
开发者ID:SinishaDjukic,项目名称:Meshwork,代码行数:31,代码来源:BaseRFApplication.cpp

示例9: udp_server_task

void udp_server_task(void const *argument)
{
    DigitalOut indicator(LED1);
    UDPSocket server;

    server.bind(ECHO_SERVER_PORT);
    // printf("[udp_server_task] Start\r\n");

    Endpoint client;
    char buffer[BUFFER_SIZE] = { 0 };
    while (true) {
        //printf("[udp_server_task] Wait for packet...\r\n");
        int n = server.receiveFrom(client, buffer, sizeof(buffer));
        if (n > 0) {
            //printf("[udp_server_task] Received packet from: %s\r\n", client.get_address());
            const int buffer_string_end_index = n >= BUFFER_SIZE ? BUFFER_SIZE - 1 : n;
            buffer[buffer_string_end_index] = '\0';
            //printf("[udp_server_task] Server received: %s\r\n", buffer);
            if (host_port == 0) {
                strcpy(host_address, client.get_address());
                host_port = ECHO_SERVER_PORT + 1;
                //printf("[udp_server_task] Set host address and port: %s:%d\r\n", host_address, host_port);
            }
            // Dispatch data to client for sending to test HOST
            cli_serv_mutex.lock(); // LOCK
            // Push to datagram queue
            datagram_queue.push_front(std::string(buffer));
            max_queue_len = datagram_queue.size() > max_queue_len ? datagram_queue.size() : max_queue_len;
            received_packets++;
            cli_serv_mutex.unlock(); // LOCK
            indicator = !indicator;
        }
    }
}
开发者ID:23chrischen,项目名称:mbed,代码行数:34,代码来源:main.cpp

示例10: throw

	void BroadcastReceiver::operator() (timeval *pTimeout) throw (FatalError)
	{
		// only one thread allowed per instance
		if(0 == std::atomic_fetch_add(&mNumInstances, 1))
			try {
				size_t numRemotes = mIpTable.size();
				timeval endTime, now;
				gettimeofday(&endTime, NULL);
				timeval_add(&endTime, pTimeout);
				do
				{
					const Endpoint remote = GetNextRemote(pTimeout);
					if(remote.IsValid()) {
						numRemotes++;
					}
					gettimeofday(&now, NULL);
				}
				while(mIsRunning && timeval_sub(&endTime, &now, pTimeout));
			} catch(FatalError& e) {
				std::atomic_fetch_sub(&mNumInstances, 1);
				throw(e);
			}



		std::atomic_fetch_sub(&mNumInstances, 1);
	}
开发者ID:Balu1991,项目名称:Wifly_Light,代码行数:27,代码来源:BroadcastReceiver.cpp

示例11: ArbiterError

std::unique_ptr<fs::LocalHandle> Arbiter::getLocalHandle(
        const std::string path,
        const Endpoint& tempEndpoint) const
{
    std::unique_ptr<fs::LocalHandle> localHandle;

    if (isRemote(path))
    {
        if (tempEndpoint.isRemote())
        {
            throw ArbiterError("Temporary endpoint must be local.");
        }

        std::string name(path);
        std::replace(name.begin(), name.end(), '/', '-');
        std::replace(name.begin(), name.end(), '\\', '-');
        std::replace(name.begin(), name.end(), ':', '_');

        tempEndpoint.put(name, getBinary(path));

        localHandle.reset(
                new fs::LocalHandle(tempEndpoint.root() + name, true));
    }
    else
    {
        localHandle.reset(
                new fs::LocalHandle(fs::expandTilde(stripType(path)), false));
    }

    return localHandle;
}
开发者ID:connormanning,项目名称:arbiter,代码行数:31,代码来源:arbiter.cpp

示例12: TEST_THROWS

void SuiteEndpoint::Test()
{
    // Test bad DNS look ups
    Endpoint ep;
    TEST_THROWS(ep.SetAddress(Brn("baddomainname.linn.co.uk")), NetworkError);
    TEST_THROWS(Endpoint ep2(1234, Brn("baddomainname.linn.co.uk")); (void)ep2, NetworkError);
}
开发者ID:chinshou,项目名称:ohNet,代码行数:7,代码来源:TestNetwork.cpp

示例13: walkDDRBus

/**
 * Walks the source DDR bus passed in out to the ending unit, and then
 * creates the DDRSystemBus object that contains information about the whole path
 */
void walkDDRBus(DDRBus* i_sourceBus, endpointType i_type, MemMcs * i_mcs)
{
    DDRBus* bus = i_sourceBus;
    Endpoint* source = (i_type == SOURCE) ? &i_sourceBus->source() : &i_sourceBus->endpoint();
    Endpoint* endpoint = (i_type == SOURCE) ? &i_sourceBus->endpoint() : &i_sourceBus->source();
    endpointType type = (i_type == SOURCE) ? ENDPOINT : SOURCE;
    bool done = false;


    //only need to walk busses if there's more than 1 segment
    if (endpoint->unit().empty())
    {
        do
        {
            bus = mrwGetNextBus<DDRBus>(bus, type);

            if (!bus) break;

            if (type == SOURCE)
                done = !bus->source().unit().empty();
            else
                done = !bus->endpoint().unit().empty();



        } while (!done);
    }


    if (!bus)
    {
        ostringstream msg;
        msg << "Couldn't complete a DDR bus that started at " <<
                i_sourceBus->plug()->path() << "/" << i_sourceBus->source().id() << "/" << i_sourceBus->source().unit();
        mrwError(msg.str());

        return;
    }


    //the midpoint of the system bus - the source of the DDR/end of the DMI.
    //The ID of i_sourceBus->source() is the centaur instance
    //The unit of i_sourceBus->source is the DDR unit
    MemMba* mba = new MemMba(i_sourceBus->plug(), *source);

    //the destination of the system bus, the DIMM
    MemDram* dram = new MemDram(bus->plug(), (type == SOURCE) ? bus->source() : bus->endpoint());

    if (mrwLogger::getDebugMode())
    {
        string m = "Found DDR endpoint " + mrwUnitPath(dram->plug(), dram->dramEndpoint());
        mrwLogger::debug(m);
    }

    //the whole system bus
    MemSystemBus* systemBus = new MemSystemBus(i_mcs, mba, dram);

    g_systemBusList.push_back(systemBus);

}
开发者ID:brs332,项目名称:openpower-mrw-old,代码行数:64,代码来源:mrwMemCommon.C

示例14: NMSend

NMSInt32
NMSend(
    NMEndpointRef	inEndpoint,
    void			*inData,
    NMUInt32			inSize,
    NMFlags			inFlags)
{
    DEBUG_ENTRY_EXIT("NMSend");

    NMSInt32			rv;
    NMIPEndpointPriv	*epRef;
    Endpoint 			*ep;
    NMErr				status = kNMNoError;

    op_vassert_return((inEndpoint != NULL),"Endpoint is NIL!",kNMParameterErr);
    op_vassert_return((inData != NULL),"Data pointer is NULL!",kNMParameterErr);
    op_vassert_return((inSize > 0),"Data size < 1!",kNMParameterErr);

    epRef = (NMIPEndpointPriv *) inEndpoint;
    ep = epRef->ep;

    op_vassert_return((ep != NULL),"Private endpoint is NIL!",kNMParameterErr);
    op_vassert_return((epRef->id == kModuleID),"Endpoint id is not mine!",kNMParameterErr);

    //	Send returns the number of bytes actually sent, or an error
    rv = ep->Send(inData, inSize, inFlags);
    return (rv);
}
开发者ID:mctully,项目名称:tntbasic,代码行数:28,代码来源:NetModuleIP.cpp

示例15: resolve_no_block

            void resolve_no_block(
                implementation_type & impl, 
                NetName const & name, 
                error_code & ec)
            {
                Endpoint svc;
                svc_cache_.find(name, svc, ec);
                if (ec) {
                    impl->ec = ec;
                    impl->state = ResolveTask::finished;
                    return;
                }
                // 可能service只有一种
                impl->name = name;
                impl->name.protocol((NetName::ProtocolEnum)svc.protocol());
                impl->endpoints.clear();
                impl->ec.clear();
                bool found = host_cache_.find(impl->name, impl->endpoints);
                if (found) {
                    for (size_t i = 0; i < impl->endpoints.size(); ++i) {
                        impl->endpoints[i].port(svc.port());
                    }
                } else {
                    ec = boost::asio::error::would_block;
                }
#ifndef FRAMEWORK_NETWORK_WITH_SERVICE_CACHE
                impl->name.svc(format(svc.port()));
#endif
                impl->state = ResolveTask::waiting;
                tasks_.push_back(impl);
                if (tasks_.size() == 1 && tasks2_.empty()) {
                    sync_data_->cond.notify_one();
                }
            }
开发者ID:huangyt,项目名称:MyProjects,代码行数:34,代码来源:ResolverService.cpp


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