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


C++ recvData函数代码示例

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


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

示例1: COBDIM

/* read boco dimensions from covise */
int COBDIM(int *nrbpoi_geb, int *nwand_geb, int *npres_geb, int *nsyme_geb,
           int *nconv_geb)
{

    int data[2], r;
    int dim[6];
    r = recvData(data, 2 * sizeof(int));

    if (data[0] != BOCO_DIM)
    {
        fprintf(stderr, "Data sent from COVISE is of wrong type %d, expected type %d (BOCO_DIM)\n", data[0], BOCO_DIM);
        return -1;
    }
    if (data[1] != 24)
    {
        fprintf(stderr, "Boco dimensions sent from COVISE has wrong length %d, expected length 24\n", data[1]);
        return -1;
    }

    recvData(dim, 6 * sizeof(int));
    *nrbpoi_geb = dim[0];
    *nwand_geb = dim[1];
    *npres_geb = dim[2];
    *nsyme_geb = dim[3];
    *nconv_geb = dim[4];
    return 0;
}
开发者ID:nixz,项目名称:covise,代码行数:28,代码来源:coSimClient.C

示例2: COGDIM

/* read grid dimensions from covise */
int COGDIM(int *npoin_ges, int *nelem_ges, int *knmax_num, int *elmax_num,
           int *npoin_geb, int *nelem_geb)
{

    int data[2], r;
    int dim[9];
    r = recvData(data, 2 * sizeof(int));

    if (data[0] != GEO_DIM)
    {
        fprintf(stderr, "Data sent from COVISE is of wrong type %d, expected type %d (GEO_DIM)\n", data[0], GEO_DIM);
        return -1;
    }
    if (data[1] != 36)
    {
        fprintf(stderr, "Grid dimensions sent from COVISE has wrong length %d, expected length 36\n", data[1]);
        return -1;
    }

    recvData(dim, 9 * sizeof(int));
    *npoin_ges = dim[1];
    *nelem_ges = dim[2];
    *knmax_num = dim[3];
    *elmax_num = dim[4];
    *npoin_geb = dim[5];
    *nelem_geb = dim[6];
    return 0;
}
开发者ID:nixz,项目名称:covise,代码行数:29,代码来源:coSimClient.C

示例3: recv_handshakemsg

//Receives handshake from the socket and populates it in the hs_msg structure.
int recv_handshakemsg(handshake *hs_msg, int sockfd)
{
	unsigned char *recvbuf = NULL;
	recvbuf = give_mem(recvbuf, 20);
	if (recvData(sockfd, recvbuf, 20) == FAILURE)
	{
		printf("Receiving protocol-length and protocol_name failed\n");
		return FAILURE;
	}
	memcpy(hs_msg->protocol_name, recvbuf, 20);
	if (recvData(sockfd, recvbuf, 20) == FAILURE)
	{
		printf("Receiving info_hash failed\n");
		return FAILURE;
	}
	
	memcpy(hs_msg->info_hash,recvbuf,20);
	//recv peer id - 20 bytes hs_msg->peer_id
	if (recvData(sockfd, recvbuf, 20) == FAILURE)
	{
		printf("Receiving info_hash failed\n");
		return FAILURE;
	}
	memcpy(hs_msg->peer_id, recvbuf, 20);

	free(recvbuf);

	return SUCCESS;
}
开发者ID:kwahome,项目名称:BitTorrent-Protocol-Implementation,代码行数:30,代码来源:bt_lib.c

示例4: recvData

int CommunicationServices::receiveReq( int sock, Message *msg )
{		
	//point to header
	MessageHeader *hdr = &msg->hdr;

	// read the message header 
	recvData( sock, (char *)hdr, sizeof(MessageHeader), 
		   sizeof(MessageHeader) );
	hdr->length = ntohs(hdr->length);
	assert( hdr->length < MAX_BODY_SIZE );
	hdr->msgtype = ntohs( hdr->msgtype );
	
	// Display header	
	cout<< "Received message on socket" << sock << " with msgtype = "
		<< hdr->msgtype << "and length =" << hdr->length<<"\n";
				   

	// set the socket
	msg->sock = sock;

	// set body size
	msg->body = new char[hdr->length];	

	// read the message body
	if ( hdr->length > 0 )
		return(  recvData( sock, msg->body, hdr->length, hdr->length ) );

	return( 0 );
}
开发者ID:ethersoul,项目名称:server,代码行数:29,代码来源:CommunicationServices.cpp

示例5: switch

bool OneWireSlave::recvAndProcessCmd() {
    char addr[8];

    for (;;) {
      switch (recv() ) {
        case 0xF0: // SEARCH ROM
            search();
            return FALSE;
        case 0x33: // READ ROM
            sendData(rom, 8);
            if (errno != ONEWIRE_NO_ERROR)
                return FALSE;
            break;
        case 0x55: // MATCH ROM
            recvData(addr, 8);
            if (errno != ONEWIRE_NO_ERROR)
                return FALSE;
            for (int i=0; i<8; i++)
                if (rom[i] != addr[i])
                    return FALSE;
            return TRUE;
        case 0xCC: // SKIP ROM
            return TRUE;
        default: // Unknow command
            if (errno == ONEWIRE_NO_ERROR)
                break; // skip if no error
            else
                return FALSE;
      }
    }
}
开发者ID:eddyst,项目名称:Arduino,代码行数:31,代码来源:OneWireSlave.cpp

示例6: sizeof

void MF_ContentSocketManager::sendGetResponseMessage(vector<u_char *> *v, u_int UID, u_int reqID, u_int size, u_int srcGUID, u_int dstGUID, mfflag_t opts){
	struct MsgGetResponseReply reply;
	reply.UID = UID;
	reply.reqID = reqID;
	reply.type = MSG_TYPE_GET_RESPONSE_REPLY;
	reply.retValue = STACK_ACTION_SUCCESS;
	_system->getSocketServer()->send((char *)(&reply), sizeof(struct MsgGetResponseReply), &cliAddr);
	MF_Log::mf_log_time("MF_ContentSocketManager:sendGetResponseMessage GET_RESPONSE_TIME request number [%lu] REPLIED", reqID);
	if(recvData(v, size)){
		MF_Log::mf_log(MF_ERROR, "MF_ContentSocketManager:sendGetResponseMessage error transfering from API layer");
		return;
	}
	struct MsgGetResponseComplete msc;
	msc.UID = UID;
	msc.reqID = reqID;
	msc.type = MSG_TYPE_GET_RESPONSE_COMPLETE;
	_system->getSocketServer()->send((char *)(&msc), sizeof(struct MsgGetResponseComplete), &cliAddr);
	//pass data to transport
	MF_EvDownAPI *newEvent;
	//NOTE: now srcGUID and dstGUID are getting swapped because they still are the original src and dst of the get request
	//TODO: make this swapping more clear
	MF_Log::mf_log(MF_DEBUG, "MF_ContentSocketManager:sendGetResponseMessage passing new message to transport. Size=%u, Src=%d, Dst=%d, opts=%lu", size, dstGUID, srcGUID, opts);
	newEvent = new MF_EvDownAPI(trnsp, v, size, dstGUID, srcGUID, setMFFlag(opts, MF_CONTENT_RESPONSE));
	_system->getEventQueue()->add(newEvent);
}
开发者ID:crockct,项目名称:GNRS-DOS,代码行数:25,代码来源:mfcontentsocketmanager.cpp

示例7: recvData

//------------------------------------------------------------------------------
// Send and receive test messages
//------------------------------------------------------------------------------
void Echo::updateData(const Eaagles::LCreal dt)
{
    // Update base classes stuff
    BaseClass::updateData(dt);

    if (areNetworksEnabled()) {
        // Looking for a message from the client
        char buffer[MAX_SIZE+1];
        unsigned int n = recvData(buffer, MAX_SIZE);
        std::cout << "n = " << n << std::endl;
        if (n > 0) {
            buffer[n] = 0;
            std::cout << "RECV: " << buffer << std::endl;
            // And send it right back to the client
            Eaagles::lcSleep(1000);
            bool ok = sendData(buffer, n);
            if (ok) {
               std::cout << "SENT: " << buffer << std::endl << std::endl;

               // End check
               loopCounter++;
               if (getLoops() > 0 && loopCounter >= getLoops()) {
                   closeConnections();
                   std::cout << "Exit: " << getLoops() << " loops completed!" << std::endl;
                   std::exit(0);
               }

            }
        }
    }
}
开发者ID:dfileccia,项目名称:OpenEaaglesExamples,代码行数:34,代码来源:Echo.cpp

示例8: coGetParaText

/* Read a Text Parameter of the module */
int coGetParaText(const char *name, char *data)
{
   if (coSendC(GET_TEXT_PARA,name))
      return -1;;
   if (   recvData((void*)&data,256,BSWP_DONTSWAP) != 256 ) 
      return -1;
   return 0;
}
开发者ID:dwickeroth,项目名称:covise,代码行数:9,代码来源:coSimClient.c

示例9: coGetParaFile

/* Read a Filename Parameter of the module */
int coGetParaFile(const char *name, int *data)            /* Fortran 77: COGPFI() */
{
   if (coSendC(GET_FILE_PARA,name))
      return -1;;
   if (   recvData((void*)&data,256,BSWP_DONTSWAP) != 256 ) 
      return -1;
   return 0;
}
开发者ID:dwickeroth,项目名称:covise,代码行数:9,代码来源:coSimClient.c

示例10: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    shareFrameData threadShareData(640, 480);
    NetWorkHandle netWorkThread;
    MainWindow w;
    QWidget mainWidget(&w);
    QHBoxLayout mainLayout;
    QVBoxLayout leftLayout;
    QVBoxLayout rightLayout;
    QHBoxLayout controlLayout;
    QVBoxLayout statuLayout;

    MyVideoView videoView(&w);
    MyButton flyControl(&w);
    MyButton otherSet(&w);
    MyButton balanceStatu(&w);
    MyButton paramStatu(&w);
    w.setMinimumSize(QSize(800, 480));

    flyControl.setText(QString("flycontrol"));
    otherSet.setText(QString("otherset"));
    balanceStatu.setText(QString("balance param"));
    paramStatu.setText(QString("net & other statu"));
    //w.setCentralWidget(&button);

    leftLayout.addWidget(&videoView);
    leftLayout.setStretch(0, 7);
    controlLayout.addWidget(&flyControl);
    controlLayout.addWidget(&otherSet);
    leftLayout.addLayout(&controlLayout);
    leftLayout.setStretch(1, 3);

    mainLayout.addLayout(&leftLayout);
    mainLayout.setStretch(0, 7);

    rightLayout.addWidget(&balanceStatu);
    rightLayout.addWidget(&paramStatu);
    //mainLayout.setStretchFactor(&leftLayout, 5);
    //mainLayout.setStretchFactor(&rightLayout, 15);
    mainLayout.addLayout(&rightLayout);
    mainLayout.setStretch(1, 3);

    mainWidget.setLayout(&mainLayout);

    w.setCentralWidget(&mainWidget);

    QObject::connect(&netWorkThread, SIGNAL(recvData()), &videoView, SLOT(flushScreen()));
    netWorkThread.setShareBuff(&threadShareData);
    videoView.setShareBuff(&threadShareData);
    //start net work thread
    netWorkThread.start();


    w.show();

    return a.exec();
}
开发者ID:jiangshipengv8,项目名称:-fouraxisControlPanel,代码行数:58,代码来源:main.cpp

示例11: coGetParaBo

/* Common Slider code for C and Fortran */
static int coGetParaBo(int *val)   /* Receive result */
{
   struct { int32 val ; int32 error; } ret;
   if (   recvData((void*)&ret,sizeof(ret),BSWP_MUSTSWAP) != sizeof(ret)
       || ret.error ) 
      return -1;
    
   *val = ret.val;
   return 0;
}
开发者ID:dwickeroth,项目名称:covise,代码行数:11,代码来源:coSimClient.c

示例12: main

int main(void)
{
	char buf[256];
	int ret;
	
	ret = recvData(buf, 256);
	if (ret == 0)
		printf("%s", buf);
	return 0;
}
开发者ID:guolilong2012,项目名称:study,代码行数:10,代码来源:recv.c

示例13: recvMip

/**
 * Recieves and parses a packet from the MIP daemon
 * @param recvd Recieved packet
 */
void recvMip(struct mipd_packet *recvd) {
	//if(debug) fprintf(stderr, "MIPTP: recvMip(%p)\n", recvd);
	uint16_t msglen = recvd->content_len;

	struct tp_packet *tpp = malloc(msglen);
	memset(tpp, 0, msglen);
	memcpy(tpp, recvd->content, msglen);

	if(msglen == sizeof(struct tp_packet)) recvAck(tpp);
	else recvData(tpp, msglen, recvd->dst_mip);
}
开发者ID:antons1,项目名称:MIP-daemon,代码行数:15,代码来源:gbn.c

示例14: coGetParaScaFlo

/* Common Slider code for C and Fortran */
static int coGetParaScaFlo(float *val)       
{
   /* Receive result */
   struct { float val ; int32 error; } ret;
   if (   recvData((void*)&ret,sizeof(ret),BSWP_MUSTSWAP) != sizeof(ret)
       || ret.error ) 
      return -1;
    
   *val = ret.val;
   return 0;
}
开发者ID:dwickeroth,项目名称:covise,代码行数:12,代码来源:coSimClient.c

示例15: bcastData

/**
 * Called when running on the host, the function for broadcasting data between processes
 */
struct value_defn bcastData(struct value_defn to_send, int source, int threadId, int totalProcesses, int hostCoresBasePid) {
	if (threadId==source-hostCoresBasePid) {
		int i;
		for (i=0;i<totalProcesses;i++) {
			if (i == threadId) continue;
			sendData(to_send, i, threadId, hostCoresBasePid);
		}
		return to_send;
	} else {
		return recvData(source, threadId, hostCoresBasePid);
	}
}
开发者ID:caidongyun,项目名称:epython,代码行数:15,代码来源:host-functions.c


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