I've got a Linux machine that's connected (by exterior NICs) to two exterior domain names. I wish to obtain the names from the domain names my machine is attached to programmatically using C++. How do i get each one of these names during my application?

Incidentally, I've already attempted getnameinfo, also it does not work with me. So please suggest another answer.

Also, it might be more useful in my experience in case your solutions incorporated sample code.