/* 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; }
/* 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; }
//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; }
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 ); }
trap_retval RemoteGet( void *data, trap_elen len ) { unsigned_16 rec_len; len = len; _DBG_NET(("RemoteGet\r\n")); if( IS_VALID_SOCKET( data_socket ) ) { int size; size = recvData( &rec_len, sizeof( rec_len ) ); #ifdef __RDOS__ while( size == 0 ) { if( !IS_VALID_SOCKET( data_socket ) ) return( REQUEST_FAILED ); size = recvData( &rec_len, sizeof( rec_len ) ); } #endif if( size == sizeof( rec_len ) ) { CONV_LE_16( rec_len ); #ifdef __RDOS__ if( rec_len && recvData( data, rec_len ) == rec_len ) { #else if( rec_len == 0 || recvData( data, rec_len ) == rec_len ) { #endif _DBG_NET(("Got a packet - size=%d\r\n", rec_len)); return( rec_len ); } } } return( REQUEST_FAILED ); } trap_retval RemotePut( void *data, trap_elen len ) { unsigned_16 send_len; int snd; _DBG_NET(("RemotePut\r\n")); if( IS_VALID_SOCKET( data_socket ) ) { send_len = len; CONV_LE_16( send_len ); snd = send( data_socket, (void *)&send_len, sizeof( send_len ), 0 ); if( IS_RET_OK( snd ) ) { if( len != 0 ) snd = send( data_socket, data, len, 0 ); if( len == 0 || IS_RET_OK( snd ) ) { #ifdef __RDOS__ RdosPushTcpConnection( data_socket ); #endif _DBG_NET(("RemotePut...OK\r\n")); return( len ); } } } return( REQUEST_FAILED ); }
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; } } }
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); }
//------------------------------------------------------------------------------ // 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); } } } } }
void MF_ContentSocketManager::sendGetMessage(vector<u_char *> *v, u_int UID, u_int reqID, u_int size, u_int dstGUID, mfflag_t opts){ struct MsgGetReply reply; reply.UID = UID; reply.reqID = reqID; reply.type = MSG_TYPE_GET_SEND_REPLY; reply.retValue = STACK_ACTION_SUCCESS; _system->getSocketServer()->send((char *)(&reply), sizeof(struct MsgGetReply), &cliAddr); MF_Log::mf_log_time("MF_ContentSocketManager:sendGetMessage SEND_TIME request number [%lu] REPLIED", reqID); if(recvData(v, size)){ MF_Log::mf_log(MF_ERROR, "MF_ContentSocketManager:sendGetMessage error transfering from API layer"); return; } struct MsgGetSent msc; msc.UID = UID; msc.reqID = reqID; msc.type = MSG_TYPE_GET_SEND_COMPLETE; _system->getSocketServer()->send((char *)(&msc), sizeof(struct MsgGetSent), &cliAddr); //Add get to pendingGet pendingGet.insert(make_pair(dstGUID, reqID)); //pass data to transport MF_EvDownAPI *newEvent; if(GUIDs.empty()){ MF_Log::mf_log(MF_DEBUG, "MF_ContentSocketManager:sendGetMessage passing new message to transport. Size=%u, Src=%d, Dst=%d, opts=%lu", size, 0, dstGUID, opts); newEvent = new MF_EvDownAPI(trnsp, v, size, 0, dstGUID, setMFFlag(opts, MF_CONTENT_REQUEST)); } else{ MF_Log::mf_log(MF_DEBUG, "MF_ContentSocketManager:sendGetMessage passing new message to transport. Size=%u, Src=%d, Dst=%d, opts=%lu", size, GUIDs.front(), dstGUID, opts); newEvent = new MF_EvDownAPI(trnsp, v, size, GUIDs.front(), dstGUID, setMFFlag(opts, MF_CONTENT_REQUEST)); } _system->getEventQueue()->add(newEvent); }
/* 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; }
/* 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; }
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(¶mStatu); //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(); }
/* 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; }
int main(void) { char buf[256]; int ret; ret = recvData(buf, 256); if (ret == 0) printf("%s", buf); return 0; }
/** * 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); }
/* 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; }
void SelfListener::run() { while (_running) { boost::intrusive_ptr<RefCntBuffer> b; int bytes = _targetInterface->tgtRead(b); if (bytes > 0) { emit recvData(b); } } }
/** * 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); } }
int XC::TrigSeries::recvSelf(const CommParameters &cp) { static ID data(3); const int dataTag = this->getDbTag(); int result = cp.receiveIdData(getDbTagData(),dataTag); if(result<0) std::cerr << "TrigSeries::sendSelf() - ch failed to receive data\n"; else result+= recvData(cp); return result; }
//! @brief Receives object through the channel being passed as parameter. int XC::CorotTruss::recvSelf(const CommParameters &cp) { inicComm(22); const int dataTag= getDbTag(); int res= cp.receiveIdData(getDbTagData(),dataTag); if(res<0) std::cerr << getClassName() << "::" << __FUNCTION__ << "; failed to recv ID data"; else res+= recvData(cp); return res; }
/** * Broadcasts data, if this is the source then send it, all cores return the data (even the source) */ struct value_defn bcastData(struct value_defn to_send, int source, int totalProcesses) { if (myId==source) { int i; for (i=0;i<totalProcesses;i++) { if (i == myId) continue; sendData(to_send, i); } return to_send; } else { return recvData(source); } }
void* threadRecv(void *p) { RUDPSOCKET a = (RUDPSOCKET*)p; pthread_detach(pthread_self()); recvData(a); //sendData(a); RUDPClose(a); sleep(5); return NULL; }
//! @brief Receives object through the channel being passed as parameter. int XC::Beam2dPartialUniformLoad::recvSelf(const CommParameters &cp) { inicComm(7); const int dataTag= getDbTag(); int res= cp.receiveIdData(getDbTagData(),dataTag); if(res<0) std::cerr << getClassName() << "::" << __FUNCTION__ << "; data could not be received\n" ; else res+= recvData(cp); return res; }
int COGPFI(const char *name, char *data, int lenNane, int lenData) { char buffer[256]; int i; if (coSendFTN(GET_FILE_PARA,name,lenNane)) return -1; if ( recvData((void*)&buffer,256,BSWP_DONTSWAP) != 256 ) return -1; strcpy(data,buffer); for (i=strlen(buffer);i<256;i++) /* FORTRAN is blank padded */ data[i]=' '; return 0; }
//! @brief Receives object through the channel being passed as parameter. int XC::PathSeries::recvSelf(const CommParameters &cp) { inicComm(6); const int dataTag = this->getDbTag(); int result = cp.receiveIdData(getDbTagData(),dataTag); if(result<0) std::cerr << getClassName() << "::" << __FUNCTION__ << "; ch failed to receive data\n"; else result+= recvData(cp); return result; }
void *FricXactor::Receive(void *args) { for(;;) { boost::shared_ptr<FricData> recvData(new FricData("FricRecieve")); _recvPacket(recvData->ptype, recvData->port, recvData->addr, recvData->data); outChan.put(recvData); ExecuteCallbacks(RecieveCB, recvData.get()); } return 0; }
/* Common Slider code for C and Fortran */ static int coGetParaSli(float *min, float *max, float *val) { /* Receive result */ struct { float min,max,val ; int32 error; } ret; if ( recvData((void*)&ret,sizeof(ret),BSWP_MUSTSWAP) != sizeof(ret) || ret.error ) return -1; *min = ret.min; *max = ret.max; *val = ret.val; return 0; }
int CORGEO() { int data[2], r; r = recvData(data, 2 * sizeof(int)); if (data[0] != SEND_GEO) { fprintf(stderr, "Data sent from COVISE is of wrong type %d, expected type %d (SEND_GEO)\n", data[0], SEND_GEO); return -1; } return 0; };
void QNRSBatchWidget::batchSlot() { QString batchOperations=batchOperationsTextEdit->document()->toPlainText().trimmed(); QString accessKey=this->accessKeyLineEdit->text().trimmed(); QString secretKey=this->secretKeyLineEdit->text().trimmed(); QByteArray secretKeyBytes=secretKey.toLocal8Bit(); QNMac mac(accessKey,secretKeyBytes); QNetworkRequest request=QNRS::batchRequest(batchOperations,&mac); QByteArray postData=batchOperations.toLocal8Bit(); QNetworkReply *reply=networkManager.post(request,postData); connect(reply,SIGNAL(finished()),this,SLOT(recvData())); connect(reply,SIGNAL(error(QNetworkReply::NetworkError)), this,SLOT(handleError(QNetworkReply::NetworkError))); }
// Check received PDUs for HCI tunnelling or dummy events void BlueCoreTransportImplementation::recvTunnel ( const uint8 *apdu, size_t aLength ) { // first three bytes contain the header for the tunnel data packet // (2 Byte HCI Header + 1 Tunnel byte). if ( ( 3 <= aLength ) && ( apdu[0] == HCI_TUNNEL_EVENT ) && ( apdu[1] == aLength - 2 ) ) { // Reassemble HCI tunnelling packet PDU::bc_channel channel = PDU::bc_channel(apdu[2] & HCI_TUNNEL_CHANNEL_MASK); if ((PDU::zero <= channel) && (channel < PDU::csr_hci_extensions_count)) { bool first = (apdu[2] & HCI_TUNNEL_FIRST) != 0; bool last = (apdu[2] & HCI_TUNNEL_LAST) != 0; if ( first && last ) { // ignore the building vector, and just send up. recvData ( channel , apdu + 3 , aLength - 3 ); } else { if (first) mRecvTunnel[channel].clear(); // Add the new fragment to the buffer mRecvTunnel[channel].insert( mRecvTunnel[channel].end() , apdu + 3 , apdu + aLength ); if ( last ) recvData ( channel , &mRecvTunnel[channel][0] , mRecvTunnel[channel].size() ); } } } else { // If tunneling generates dummy command completes, they'll be sent up too. mReceiver.onPDU ( PDU::hciCommand , apdu , aLength ); } }