Hi!
I've been trying to connect two Android devices (2.1) via TCP sockets. The vital part of the code:
Server: ServerSocket serverSocket = new ServerSocket(SERVERPORT);
Client: Socket socket = new Socket(serverAddr, SERVERPORT);
The weird thing is I can make it work if the client is an emulator, but the same code fails if running both of them on real devices. The failure in the client side is:
java.net.SocketException: No route to host
at org.apache.harmony.luni.platform.OSNetworkSystem.connectSocketImpl(Native
Method)
at org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.
java:114)
at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:
245)
at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:
220)
at java.net.Socket.startupSocket(Socket.java:780)
at java.net.Socket.(Socket.java:314)
I tried with WIFI and mobile net too, they were in the same subnet both times, INTERNET permission is given, the server is addressed through its real 192.168.. IP.
I am planning to change the socket implementation with setCustomSocketImplFactory().
The problem is crucial in the process of implementing MSRP protocol to Android.
Can anyone give me some advice?
Thanks!
Peter