The following explains how to configure an Android AVD to communicate with the host machine.
Add this to the manifest.xml file which allows the app to create a socket
The Android AVD sits behind a virtual router with an IP of 10.0.2.1
To communicate with the host machine the Android application needs to talk to 10.0.2.2. This IP is mapped to the localhost loopback IP 127.0.0.1.
For example you have a server application running on the host listening to port 7777. The application running on the AVD will need to connect using 10.0.2.2 port 7777.
To pass data from a desktop client to an AVD it is necessary to set up a port redirect on the AVD router. To do this connect to the AVD using telnet, the first emulator port is 5554 (telnet localhost 5554). Then use the redir add command to setup the redirect. For example to redirect incoming TCP connections from the localhost to the AVD on port 5000 use the following redir add tcp:5000:5000. Any data passed to port 5000 on the localhost (127.0.0.1:5000) will redirected to port 5000 on the AVD (10.0.2.15:5000).