1. Create a sample Hello.idl file struct Hello { string(128) msg; }; 2. Run rtiddsgen to generate the corresponding code rtiddsgen -language C++ -example Hello.idl 3. Delete the listener part from the subscriber example. /* Create data reader listener */ //reader_listener = new Article100Listener(); //if (reader_listener == NULL) { // printf("listener instantiation error\n"); // subscriber_shutdown(participant, subscriber, topic, reader); // return -1; //} When creating a data reader, set the LISTENER parameter to NULL and the MASK to NONE. /* To customize data reader QoS, use subscriber->get_default_datareader_qos() instead */ /*reader = subscriber->create_datareader( topic, DDS_DATAREADER_QOS_DEFAULT, reader_listener, DDS_STATUS_MASK_ALL);*/ reader = subscriber->create_datareader( topic, DDS_DATAREADER_QOS_DEFAULT, NULL, DDS_STATUS_MASK_NONE); 4. In subscriber_main, create a condition and waitset. In the main loop, wait until the condition is triggered: DDSStatusCondition *statusCondition = NULL; DDSWaitSet *waitset = NULL; DDSConditionSeq active_conditions; DDS_Duration_t timeout = {10, 0}; HelloDataReader *Hello_reader = NULL; HelloSeq data_seq; DDS_SampleInfoSeq info_seq; int i = 0; /* Create wait condition for read */ DDSReadCondition* readCondition = NULL; readCondition = reader->create_readcondition( DDS_ANY_SAMPLE_STATE, DDS_ANY_VIEW_STATE, DDS_ANY_INSTANCE_STATE); if (readCondition == NULL) { printf("create_readCondition error\n"); subscriber_shutdown(participant, subscriber, topic, reader); return -1; } /* create waitset */ waitset = new DDSWaitSet(); if (waitset == NULL) { printf("waitset error\n"); subscriber_shutdown(participant, subscriber, topic, reader); return -1; } /* attach status condition to waitset */ retcode = waitset->attach_condition(readCondition); if (retcode != DDS_RETCODE_OK) { printf("attach_condition error\n"); subscriber_shutdown(participant, subscriber, topic, reader); delete waitset; return -1; } /* Main loop */ while ((sample_count == 0) || (count < sample_count)) { printf("Hello subscriber waiting for samples ...\n"); retcode = waitset->wait(active_conditions, timeout); if (retcode != DDS_RETCODE_OK) { printf("wait error\n"); subscriber_shutdown(participant, subscriber, topic, reader); delete waitset; return -1; } /* take data */ Hello_reader = (HelloDataReader *)reader; retcode = Hello_reader->take_w_condition( data_seq, info_seq, DDS_LENGTH_UNLIMITED, readCondition); if (retcode == DDS_RETCODE_NO_DATA) { continue; } else if (retcode != DDS_RETCODE_OK) { printf("take error %d\n", retcode); continue; } /* print data */ for (i = 0; i < data_seq.length(); ++i) { ++count; if (info_seq[i].valid_data) { HelloTypeSupport::print_data(&data_seq[i]); } } /* return loan */ retcode = Hello_reader->return_loan(data_seq, info_seq); if (retcode != DDS_RETCODE_OK) { printf("return loan error %d\n", retcode); } } /* while count < sample_count */ /* Delete all entities */ status = subscriber_shutdown(participant, subscriber, topic, reader); delete waitset; For more information, refer to the User's Manual (DDS Entities chapter - Conditions and WaitSets).