I am trying to install on a ServerSocket on my Android phone and send either int or something from my computer.
The code on the phone creates a ServerSocket, and then blocks while waiting for a connection:
ServerSocket serverSocket = ServerSocketFactory.getDefault() .createServerSocket(4444); Log.d("HostThread", "ServerSocket created:"+serverSocket .getInetAddress().getHostAddress()); Socket socket = serverSocket.accept();
(The magazine says "10-27 11: 41: 43.437: DEBUG / HostThread (23957): ServerSocket created: 0.0.0.0")
A simple bit of code running on my PC is trying to connect to the phone:
Socket s = new Socket("xx.xx.xx.xx", 4444);
... (plus a few more bits if the socket is created, but I don't understand this, so I left it!)
Basically, the phone accepts and the computer does not connect. Xx.xx.xx.xx is the public IP address of the phone I receive programmatically (and this corresponds to checking on whatismyip.com).
I installed the permission of the INTERNET on the phone. I was also able to do this in the reverse order (ServerSocket on PC, client on phone).
Any ideas I'm wrong about?
source share