int JackNetSlaveInterface::SyncRecv() { SetRcvTimeOut(); int rx_bytes = 0; packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer); // receive sync (launch the cycle) do { rx_bytes = Recv(fParams.fMtu, 0); // connection issue (return -1) if (rx_bytes == SOCKET_ERROR) { return rx_bytes; } } while (strcmp(rx_head->fPacketType, "header") != 0); if (rx_head->fDataType != 's') { jack_error("Wrong packet type : %c", rx_head->fDataType); // not the last packet... fRxHeader.fIsLastPckt = 0; return SYNC_PACKET_ERROR; } //PacketHeaderDisplay(rx_head); fRxHeader.fIsLastPckt = rx_head->fIsLastPckt; return rx_bytes; }
int JackNetMasterInterface::SyncSend() { SetRcvTimeOut(); fTxHeader.fCycle++; fTxHeader.fSubCycle = 0; fTxHeader.fDataType = 's'; fTxHeader.fIsLastPckt = (fParams.fSendMidiChannels == 0 && fParams.fSendAudioChannels == 0) ? 1 : 0; fTxHeader.fPacketSize = HEADER_SIZE + fTxHeader.fActivePorts * sizeof(int); // Data part is used to encode active ports memcpy(fTxBuffer, &fTxHeader, HEADER_SIZE); //PacketHeaderDisplay(&fTxHeader); return Send(fTxHeader.fPacketSize, 0); }
int JackNetMasterInterface::SyncSend() { SetRcvTimeOut(); fTxHeader.fCycle++; fTxHeader.fSubCycle = 0; fTxHeader.fDataType = 's'; fTxHeader.fIsLastPckt = (fParams.fSendMidiChannels == 0 && fParams.fSendAudioChannels == 0) ? 1 : 0; fTxHeader.fPacketSize = fParams.fMtu; memcpy(fTxBuffer, &fTxHeader, HEADER_SIZE); //PacketHeaderDisplay(&fTxHeader); return Send(fTxHeader.fPacketSize, 0); }