I need a function, which accept a host name and return the IP address of the same machine, and a function that performs opposite.
Are in Visual C++ such functions or have anyone an idea how to write them ?
Printable View
I need a function, which accept a host name and return the IP address of the same machine, and a function that performs opposite.
Are in Visual C++ such functions or have anyone an idea how to write them ?
Use gethostbyname and gethostbyaddr, or any of the other gethostby... functions. Both return a structure (hostent/HOSTENT) whereby you should be able to extract that information.
use gethostname to get the name of your local machine, too
Dennis