A TCP connection consists for two ends AND of the connections in between.
The fact that two ends connect does NOT mean that meaningful (non-private ip) is available on either end.
The fact that two ends connect does NOT mean that one end can recover a meaningful ip for the other end in such a way that it uniquely identifies the other end.
And of course connections have nothing to do with domain names.
Now some of the above might have something to do with your problem. Or not. But it isn't clear what you think you want (neither here nor your other post.)