the unix hostname
program gives me an exceedingly simple way to get my "real" hostname (not localhost. For example, for me it's currently unknown74e5[...]df7.att.net
). But how can I do this inside of my own code with C system calls? I'd like to get a char *
that has this string in it so that I can pass it into gethostbyname
and similar.
While I'm at it, I'd like also to know how I can get my IP address with UNIX system calls rather than relying on programs (or worse, whatismyip.com)...
Thanks!