Game Development Reference
In-Depth Information
How it works...
To enumerate all the adapters in a console window we use a simple loop:
int main()
{
std::vector<sAdapterInfo> a;
Net_EnumerateAdapters( a );
for(size_t i = 0 ; i < a.size() ; i++)
{
printf("[%d] %s\n", i + 1, a[i].FIP);
}
return 0;
}
The Android implementation of this code is in the App5 project.
There's more...
Fortunately, the code above works for any POSIX system and the App5 example also provides
a Windows version of Net_EnumerateAdapters() . On Android, we have to enable the
ACCESS_NETWORK_STATE and INTERNET permissions for our application; otherwise, the
system will not allow us to access the Internet. This is done in the AndroidManifest.xml
ile of the App5 example, using the following lines:
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>
Don't forget to put these lines into the manifest of your application, which intends to work with
the network.
Writing the HTTP server
When dealing with mobile development, we will eventually run our games on a real device.
Until then, we have to use some debugging tools. Of course, we might set up remote
debugging with gdb , but as soon as most critical bugs related to access violations are
eliminated, here come the logical errors or those related to race conditions, which are dificult
to hunt down and require multiple redeployment of the application with somewhat trivial
changes to it. To be able to quickly change the runtime behavior of your application directly on
an Android device, we can implement an embedded web server with an interface to ine-tune
some internal parameters of your application. This recipe contains an outline of App5 , which
implements such a web server.
 
Search WWH ::




Custom Search