Reputation: 578
I wrote a simple socket program on android, the server side sets up a server socket waiting for incoming connections, the client side just connect to the server by establish a connection with the server's ip address. I'm using Sprint's 3G Nexus S as the server, and ATT'S 4G Samsung galaxy S3 as client. When my client tries to connect, it throws out the exception"No route to destination". But then I switched to my personal WIFI network, it worked perfectly. Can someone help me with this issue? or is there any special requirement in android to use cellular network to set up socket connection? thank you!
My client side is:
socket = new Socket(serveripaddress, 8008);
out = new PrintWriter(socket.getOutputStream());
My server side is:
ss = new ServerSocket(8008);
update: I just used 2 Sprint cellphones to test my code and it works fine!! This is just a special case in which i have to use phone as server, it is not recommended in general
Upvotes: 2
Views: 572
Reputation: 7698
Carrier firewalls typically don't allow incoming connections to mobile devices. Doing so would leave the mobile devices open to security risks and abuse of their data limits. It can also depend on the APN used for the connection.
Upvotes: 2