Android connecting to local java ServerSocket?
I have written a basic java http server using sockets. It has simple REST interface and responds to GET/POST requests. I set out to do a small android app connecting to this interface. I can connect to my servers using browsers from my pc and also I tried out from vmware player virtual machines ubuntu and xp. All work well. I was afraid of testing on emulator so deployed the app on android phone. It cann开发者_运维知识库ot connect to the java servers. Both device and PC is connected to same network. Am I missing something here like port forwarding etc ? If that's the problem how come I was able to connect from my virtual machines?
Any help/suggestions are appreciated.
Regards, Lalith
Can you have forgotten to set the internet permission perhaps? You need this in your android manifest.
<uses-permission android:name="android.permission.INTERNET" />
/Stefan
Can you connect to this server from another PC running on the same network? (This is not the same as connecting from a virtual machine running on the same box as the server)
If not, you may have a firewall issue on the PC.
You should test on the android emulator too, use the alias for the host loopback interface address that you can find in the emulator docs.
精彩评论