gethostbyname in C
Posted
by Matic
on Stack Overflow
See other posts from Stack Overflow
or by Matic
Published on 2010-05-19T12:49:36Z
Indexed on
2010/05/19
12:50 UTC
Read the original article
Hit count: 298
gethostbyname
|c
I don't know how to write applications in C, but I need a tiny program that does:
lh = gethostbyname("localhost");
output = lh->h_name;
output variable is to be printed.
The above code is used in PHP MongoDB database driver to get the hostname of the computer (hostname is part of an input to generate an unique ID). I'm skeptical that this will return the hostname, so I'd like some proof.
Any code examples would be most helpful.
Happy day,
Matic
© Stack Overflow or respective owner