memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET; // AF_INET (IPv4) or AF_INET6 (IPv6) to force version
hints.ai_socktype = SOCK_STREAM;
getaddrinfo("localhost", NULL, &hints, &res);
I only get the loopback device this way. I need the Wifi address. Andone got a better insight what I might do wrong?
By 'Wifi Address', do you mean the ip address as seen from the outside world, or the local ip address as seen from within the network?
Either way, here's some links that may help:
http://stackoverflow.com/questions/2146191/obtaining-local-ip-address-using-getaddrinfo-c-function (http://stackoverflow.com/questions/2146191/obtaining-local-ip-address-using-getaddrinfo-c-function)
http://www.droidnova.com/get-the-ip-address-of-your-device,304.html (http://www.droidnova.com/get-the-ip-address-of-your-device,304.html)
http://beej.us/guide/bgnet/output/html/multipage/getaddrinfoman.html (http://beej.us/guide/bgnet/output/html/multipage/getaddrinfoman.html)
1.) #include <ifaddrs.h> is not in the Android NDK
2.) It's Java code. It's an emergency option, but I hope for a native solution, still.
3.) I did this. It only returns 127.0.0.1 on Android (works on about any other platform).
I love Android.
NOT!
I don't envy you having to almost master every platform in existence, with each having their own quirks.
I still only know iOS and barely at that! Well, good luck.
I couldn't find much about it unfortunately, apart from using NULL as the first parameter.
By the looks of it, it may be a bug :)