Android Networking Issues :
connect form host to
emulator , connect from emulator to host machine , ping host from emulator ,
ping emulator from host , server running in emulator and connect from through host,
server running in host machine and connect from emulator
One of the simplest
(but time eater) scenario I have faced is networking between your Android
emulator and your Host machine.
Two problems I have
faced are :
1) Connect Emulator
to a Server running in host machine
2) Connect Host
Machine to Server running in emulator
Out of these two,
second one became real headache for me. But atlast solution I found was so
simple.
**********************************************************************
Solution 1 : Connect emulator to server running in host
machine :
For emullator , IP
address of host machine is 10.0.2.2
So you can use this
IP to connect to your host machine, for example:
Let us assume a web
application ""sample" is running at port 8084 in your host
machine.
Type
http://10.0.2.2:8084/sample
and press enter, it
will print your desired output.
**********************************************************************
Solution 2:
Connect Host machine
to server running in emulator :
By default emulator
IP is 10.0.2.15 , but problem you will be facing is you can not connect using
this IP and even
you can not ping this
IP.
So solution I found
was port redirection, very simple to do :
Assume one instance
of emulator is running
Steps:
i) open command
prompt
ii) type "
telnet localhost 5554 " ans press
enter
iii)type " redir
add tcp:fromPort:whichPort " and press enter
Step 3 here redirect
your request, mean any request you will make using localhost:fromPort will
deliver to emulator:toPort
iv) you can del
redirection using command :
redir del
tcp:fromPort
v) If you are working
with udp, then use udp instead of tcp in command
i am unable to open tomcat main page running on host machine from emulator. any ideas what could be the problem?
ReplyDeleteDid you try http://10.0.2.2:8080/yourApp
DeleteReplace 8080 with your port number and don't use any if it is 80
Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. emulator android
ReplyDelete