To communicate with a web server, we need to specify its IP address. In a limited mobile environment, it is not convenient to ask the user for the IP address and we have to detect the address ourselves (and not involving any non-portable code). In the forthcoming App5
example, we use the GetAdaptersAddresses()
function from the Windows API and the getifaddrs()
function from POSIX. The Android runtime library provides its own implementation of getifaddrs()
, which is included in the App5
sources in the DetectAdapters.cpp
file.
Let's declare a structure to hold the information describing a network adapter:
struct sAdapterInfo {
This is the internal system name of the network adapter:
char FName[256];
The IP address of the adapter is as follows:
char FIP[128];
The unique identification number of the adapter:
char FID[256]; };