Android Server Socket

I am unable to reach the Android Server on the emulator from a program on my desktop, how do I solve it?

Some code (from How to find LAN ip address of android device?):

public static ArrayList<String> getSelfIP(){
    try {
        ArrayList<String> ipList = new ArrayList<>();
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
            NetworkInterface intf = en.nextElement();
            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress()) {
                    ipList.add(inetAddress.getHostAddress().toString());
                }
            }
        }

        return ipList;
    } catch (SocketException ex) {}
    return null;
}

The result is [fe80::5054:ff:fe12:3456%eth0, 10.0.2.15]

What do I have to configure or do to make the emulator reachable by my desktop programs?


Source: android

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.