I've been messing around with getaddrinfo and getnameinfo but the closest I got to useful output was "localhost.localdomain". I'm not sure what to pass in for the "node" or "service" args of getaddrinfo, although I think it's the function I want.
Actually, Zxaos's answer here is pretty much the answer I was looking for (even though it's for C and mine was for C++, it works in both):
How do I find the current machine's full hostname in C (hostname and domain information)?
So I guess my question was a duplicate...