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


C++ processPacket函数代码示例

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


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

示例1: tftpPoll

/**
 * Looks for a connection
 */
uint8_t tftpPoll()
{
	uint8_t response = ACK;
	// Get the size of the recieved data
	uint16_t packetSize = netReadWord(REG_S3_RX_RSR0);

	if(packetSize) {
		tftpFlashing = TRUE;

		for(;;) {
			if(!(netReadReg(REG_S3_IR) & IR_RECV)) break;

			netWriteReg(REG_S3_IR, IR_RECV);

			//FIXME: is this right after all? smaller delay but
			//still a delay and it still breaks occasionally
			_delay_ms(400);
		}
		// Process Packet and get TFTP response code
#ifdef _DEBUG_TFTP
		response = processPacket(packetSize);
#else
		response = processPacket();
#endif
		// Send the response
		sendResponse(response);
	}
	if(response == FINAL_ACK) {
		netWriteReg(REG_S3_CR, CR_CLOSE);
		// Complete
		return(0);
	}
	// Tftp continues
	return(1);
}
开发者ID:Zekom,项目名称:Ariadne-Bootloader,代码行数:38,代码来源:tftp.c

示例2: main

// --------------------------------------------------------------------
// main
// --------------------------------------------------------------------
int main(int argc, char*argv[]) 
{    
    parseArgs(argc, argv);

    struct sigaction a;
    a.sa_handler = traitementInterrupt;      /* fonction à lancer */
    sigemptyset(&a.sa_mask);    /* rien à masquer */
    
    sigaction(SIGTSTP, &a, NULL);       /* pause contrôle-Z */
    sigaction(SIGINT,  &a, NULL);       /* fin contrôle-C */
    sigaction(SIGTERM, &a, NULL);       /* arrêt */
    sigaction(SIGSEGV, &a, NULL);       /* segmentation fault ! */

    int sock=0;
    initSocket(sock);
    sock_=sock;
    
    ZFile file;
    initFile(&file);
    file_=&file;
    
    while(1) {
	bool close=false;
        processPacket(sock, &file, false, close);
	if (close) {
	    file.close();
	    initFile(&file);
	    file_=&file;
	}
    }
    return(EXIT_SUCCESS);
}
开发者ID:BackupTheBerlios,项目名称:robotm6,代码行数:35,代码来源:logger.cpp

示例3: playGame

void playGame(void)
{
    int len;
    struct packet p;
    lcdPrintln("Now playing:");
    lcdPrintln(gameTitle);
    lcdRefresh();

    while(1){
        uint8_t button = getInputRaw();
        sendButton(button);
        
        while(1){
            if( flags & FLAGS_LONG_RECV )
                len = nrf_rcv_pkt_time(64,sizeof(p),(uint8_t*)&p);
            else
                len = nrf_rcv_pkt_time(32,sizeof(p),(uint8_t*)&p);
                
            if(len==sizeof(p)){
                processPacket(&p);
            }else{
                break;
            }
        }
        int rnd = getRandom() % jitter;
        delayms(interval*5+rnd);
        
        volatile uint16_t i;
        i = getRandom()&0xfff;
        while(i--);

    };
}
开发者ID:Bediko,项目名称:r0ket,代码行数:33,代码来源:r_player.c

示例4: assert

NetworkServer::AutoPacket NetworkServer::receive()
{
	assert(isConnected());

	for (;;) {
		if (_queuedUser) {
			removeUser(_queuedUser);
			_queuedUser = 0;
		}

		Packet* raw = _peer->Receive();
		if (!raw) {
			return AutoPacket();
		}
		AutoDepacketer depacketer(*_peer, raw);

		AutoPacket packet(processPacket(*raw));
		if (packet.get()) {
			User *user = findUser(raw->systemAddress);
			if (!user) {
				packetHeader(std::cout, *raw);
				std::cout << "Packet from unknown user: " << int(packet->kind()) << std::endl;
				continue;
			}
			packet->read(raw, user);
			return packet;
		}
	}
}
开发者ID:weimingtom,项目名称:mmomm,代码行数:29,代码来源:networkServer.cpp

示例5: read

bool Communicator::readFromClient()
{
	bool result = false;
	ssize_t r = 0;
	uint32_t packetSize = 0;

	r = read(mSocket, &packetSize, 4);

	if (r == 4) {
		packetSize = le32toh(packetSize);
		//syslog(LOG_INFO, "incoming packet size: %d", packetSize);

		uint8_t *buf = (uint8_t *) malloc(packetSize - 4);

		r = read(mSocket, buf, packetSize - 4);

		if (r == (packetSize - 4)) {
			result = processPacket(buf, packetSize - 4);
		}
		else
			syslog(LOG_ERR, "Error reading packet : %ld", r);

		free(buf);

	} else
		syslog(LOG_ERR, "Error reading total packet size: %ld", r);



	return result;
}
开发者ID:Ivo924,项目名称:DslrDashboardServer,代码行数:31,代码来源:communicator.cpp

示例6: while

void JobThread::run()
{
   Packet* packet = NULL;
   while ( !terminated ) {
      
      packet = m_jobQueue->dequeue();

      // loop until we get a packet
      if ( packet == NULL ) {
         continue;
      }

      if ( packet->timedOut() ) {
         mc2dbg << "[JobThread]: Packet timed out, type="
                << packet->getSubTypeAsString()
                << " age "
                << float(packet->getTimeSinceArrival() / 1000.0 )
                << " max age " << packet->getTimeout() << endl;
         delete packet;
         continue;
      }

      processPacket( packet );

   }
   // make sure the dispatcher dies quickly 
   m_dispatcher.reset( NULL );
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-Server,代码行数:28,代码来源:JobThread.cpp

示例7: sleep_time

int ManageMemberSessionOutput::svc()
{
	ACE_Time_Value sleep_time(0, 1000);
	PacketVec_t	output_packet_vec;
	while (true)
	{
		{
			ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, m_output_packet_vec_mutex, 1);
			std::copy(m_output_packet_vec.begin(), m_output_packet_vec.end(), std::back_inserter(output_packet_vec));
			m_output_packet_vec.clear();
		}

		if (output_packet_vec.size() == 0)
		{
			ACE_OS::sleep(sleep_time);
			continue;
		}
	
		for (PacketVec_t::iterator it = output_packet_vec.begin(); it != output_packet_vec.end(); ++it)
		{
			Packet * packet = *it;
			processPacket(packet);
		}

		output_packet_vec.clear();
	}
	return 0;
}
开发者ID:BianJian,项目名称:steppingstone,代码行数:28,代码来源:ManageMemberSessionOutput.cpp

示例8: playGame

void playGame(void)
{
    int len;
    struct packet p;

    while(1){
        uint8_t button = getInputRaw();
        sendButton(button);
        
        while(1){
            if( flags & FLAGS_LONG_RECV )
                len = nrf_rcv_pkt_time(64,sizeof(p),(uint8_t*)&p);
            else
                len = nrf_rcv_pkt_time(32,sizeof(p),(uint8_t*)&p);
                
            if(len==sizeof(p)){
                processPacket(&p);
            }else{
                break;
            }
        }
        int rnd = getRandom() % jitter;
        delayms(interval+rnd);
    };
}
开发者ID:tuxcodejohn,项目名称:r0ket,代码行数:25,代码来源:r_player.c

示例9: savePoint

    bool WirelessParser::findPacketInBytes(DataBuffer& data, WirelessTypes::Frequency freq)
    {
        //create a read save point for the DataBuffer
        ReadBufferSavePoint savePoint(&data);

        std::size_t lastReadPosition;

        //while there are enough bytes remaining to make an ASPP response packet
        while(data.bytesRemaining() > WirelessPacket::ASPP_MIN_RESPONSE_PACKET_SIZE)
        {
            lastReadPosition = data.readPosition();

            //move to the next byte
            data.read_uint8();

            WirelessPacket packet;

            //if we found a packet within the bytes
            if(parseAsPacket(data, packet, freq) == parsePacketResult_completePacket)
            {
                //commit the data that was read
                savePoint.commit();

                //process the packet
                processPacket(packet, lastReadPosition);
                return true;
            }
        }

        //we didn't find any packet in the bytes buffer
        return false;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:32,代码来源:WirelessParser.cpp

示例10: while

//
// bool processPackets()
// Last modified: 27Aug2006
//
// Attempts to process all packets received by the cell,
// returning true if successful, false otherwise.
//
// Returns:     true if successful, false otherwise
// Parameters:  <none>
//
bool Cell::processPackets()
{
    Packet p;
    while (msgQueue.dequeue(p))
        if (!processPacket(p)) return false;
    return true;
}   // processPackets()
开发者ID:dtbinh,项目名称:lego-rover-formation,代码行数:17,代码来源:Cell.cpp

示例11: savePoint

    bool InertialParser::findPacketInBytes(DataBuffer& data)
    {
        //create a read save point for the DataBuffer
        ReadBufferSavePoint savePoint(&data);

        //while there are enough bytes remaining to make a MIP packet
        while(data.bytesRemaining() > InertialPacketInfo::MIP_MIN_PACKET_SIZE)
        {
            //move to the next byte
            data.read_uint8();

            InertialPacket packet;

            //if we found a packet within the bytes
            if(parseAsPacket(data, packet) == inertialParserResult_completePacket)
            {
                //commit the data that was read
                savePoint.commit();

                //process the packet
                processPacket(packet);
                return true;
            }
        }

        //we didn't find any packet in the bytes buffer
        return false;
    }
开发者ID:LORD-MicroStrain,项目名称:MSCL,代码行数:28,代码来源:InertialParser.cpp

示例12: connection_handler

void* connection_handler(void* argsp) {
    //Get the socket descriptor
    struct threadArgs* args = argsp;
    int client_socket = args->sock, read_size;
    List* codeList = args->list;
    free(argsp);
    unsigned char* client_message = (unsigned char*) malloc(BUFFER_SIZE);
     
    //Receive a message from client
    while((read_size = recv(client_socket, client_message, BUFFER_SIZE-1, 0)) > 0) {

        client_message[read_size] = '\0';
        processPacket(client_socket, client_message, read_size, codeList);

    }

    free(client_message);
     
    if(read_size == 0) {
        puts("Client disconnected");
    } else if(read_size == -1){
        perror("recv failed");
    }
     
    return NULL;
}
开发者ID:BigNerd95,项目名称:Samote,代码行数:26,代码来源:RCR.c

示例13: packetPrinter

void packetPrinter (u_char *user, struct pcap_pkthdr *h, u_char *pp)
{
	int rc;
	nfs_pkt_t record;

	rc = processPacket (h, pp, &record);

}
开发者ID:yoursunny,项目名称:nfsdump,代码行数:8,代码来源:iprecord.c

示例14: Packet

Packet* IPReassembly::processPacket(RawPacket* fragment, ReassemblyStatus& status, ProtocolType parseUntil, OsiModelLayer parseUntilLayer)
{
	Packet* parsedFragment = new Packet(fragment, false, parseUntil, parseUntilLayer);
	Packet* result = processPacket(parsedFragment, status, parseUntil, parseUntilLayer);
	if (result != parsedFragment)
		delete parsedFragment;

	return result;
}
开发者ID:seladb,项目名称:PcapPlusPlus,代码行数:9,代码来源:IPReassembly.cpp

示例15: processPacket

void Server::receivePackets()
{
	for (auto client = clients.begin(); client != clients.end(); ++client)
	{
		sf::Packet p;
		if (client->receive(p))
			processPacket(p, client);
	}	
}	
开发者ID:knarf0,项目名称:mmo,代码行数:9,代码来源:Server.cpp


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