Reputation: 10623
I am going to create a SOCKET connection between 2 EMULATOR, i have the below code but Nothing happens. The Server class returns me this Ip address:
10.0.2.15
and i am using this in my Client Class but nothing happens, i am not getting message at server I am using the code for both server and client from this link Socket communication between two apps on Android
please help me, i have the same code as in the above link, and i am using 10.0.2.15 in Client to connect with server
Upvotes: 2
Views: 1746
Reputation: 77
Actually the Emulator have no ip address, it always contain this type of Ip address "10.0.2.15" which is in fact can't be access from Mobile phone or other devices, because it is an emulator. in contrast the emulator can send a connection request to other server like my Mobile whose ip address is "172.23.0.101", So in this case connection will be established between emulator(as client) and Phone(as Server). In my project i have this ip address and it works well
Mobile Phone IP Add: 172.23.0.101 (SERVER)
Emulator IP Add: 10.0.2.15 (CLIENT)
Upvotes: 3
Reputation: 9276
The problem that you couldn't connect tow android emulator instances together via TCP is that they both run on a separate subnet.
Android documentations cover this topic in details and provide solutions for cases where you want to connect different emulator instances together, you can see it here: Android emulator Networking
Also there were couple of questions that are similer to your question: here and here .
Upvotes: 0
Reputation: 10623
Okkkkkk !!!, i solved my problem.I am sending messages from Emulator client to My mobile device where i have run the server program. My mobile device ip is
192.168.180.101
So, i am using this IP Address in client program and sending sms from client to server successfully.
Upvotes: 0