Android Server Socket -
i unable reach android server on emulator program on desktop, how solve it?
some code (from how find lan ip address of android device?):
public static arraylist<string> getselfip(){ try { arraylist<string> iplist = new arraylist<>(); (enumeration<networkinterface> en = networkinterface.getnetworkinterfaces(); en.hasmoreelements();) { networkinterface intf = en.nextelement(); (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 [fe80::5054:ff:fe12:3456%eth0, 10.0.2.15]
what have configure or make emulator reachable desktop programs?
i have done following:
> adb forward tcp:50000 tcp:50000
however, unable access server through localhost:50000.
try using ip address 10.0.2.2.
it special alias host loopback interface (i.e., 127.0.0.1 on development machine)
Comments
Post a Comment