[SDL] How to know the local IP address
albis at eunet.yu
Wed Apr 14 09:14:07 PDT 2004
>>If you want an other ip you had to resolve the name.domain of your
>>Just have a look at your host file and you will find the answer.
> Where is the host file in Windows ?? ;-)
It won't do you no good. Even on Linux, the computer can work without
having itself in the hosts file (for example, if DNS is installed on it,
or it uses DHCP, or it connects to Internet with modem, so IP and
hostname are different every time...)
The thing you must know that each network interface (eth, ppp, lo, etc.)
in computer can have IP address of it's own. So, one computer can have
multiple addresses, meaning that you must know what interface you wish
to query. AFAIK, Each OS has some API functions to get the list of
interfaces and their IP addresses.
For Win9x, it's in Windows instalation directory, for 2000, XP, it in
Windows/System/Drivers/etc or something like that.
> I'd like to find a standard way (if possible), to avoid having different
> ways and codes with their own #ifdef...
AFAIK, it is not possible. This looks like a typical #ifdef type of problem.
More information about the SDL