The mechanism described for your question here, using the SampleInfo, will not work for obtaining the IP address of DataReaders
Depending on the situation, the easiest approach would probably be to install a listener on your DataWriter and inspect the last_subscription_handle
parameter when the DataWriterListener’s on_publication_matched()
callback is invoked. As explained in the RTI Knowledge Base article Accessing the GUID of Connext DDS Entities, the instance handle is essentially another GUID for you to inspect.
If you have many readers that you need to keep track of, it might be easier to subscribe to the BuiltinTopics used for discovery, as explained in that same KB article. That is more work though.
Again, all of this is assuming you are looking for the IPv4 address. Also note that this is not a publicly exposed mechanism, so things might change in the future. And all of this breaks at the moment that your application explicitly sets its GUID.