Is there a way to access my host machine's network?
Specifically I want to scan host machines network and find devices connected to same network.
In short, you can't. The simulator can only talk to the host machine.
the host must provide the service to access other resources on the network.
previous text:
The android simulator is not on your home or office network.
As this was said before.. there is a small network bridge between the computer and the simulator, can you can access the host computer via the IP 10.0.2.2.
Now to access other machines on the network, or perform a scan, you basically have two choices. either the host give you access via a tunnel.
or you join the network by some other mean.
I am not sure the simulator can open a wifi connection, the device would need to be stubbed. maybe if your computer is connected via LAN cable and your wifi device delegated to the android simulator its possible.
the other choice is to use a VPN, so then every machine connected to the VPN would be on the same network.
your best bet is probably to use a real phone connected to the network via wifi.
You can access your host machine by the IP: 10.0.2.2
Related
I have a Web API Project hosted on my local system (Windows 7) on IIS7.
I am trying to access that Web API or for that matter another website hosted on the same IIS via my android mobile phone and My Mobile phone is connected to local wifi. But this IIS computer is connected to same network via wired LAN. Though I can access my router that is hosted on "xxx.xxx.1.1" IP Address from that computer as well as mobile phone but i am unable to access the IIS website from my mobile phone.
I tried turning off my windows firewall on the IIS computer where this website is running, but this didn't help as well. Although i can access this IIS website via another computer on the same LAN.
I think the issue is related to LAN or wifi but it should not be as the network and router for LAN and wifi are the same.
Need immediate help and how can i solve this.
Thanks
Can you ping your phone from your computer? Or vice-versa?
Access your router configuration and check for any access control setting that might be separating WiFi from LAN.
OK. When it was extremely urgent today, i found the answer myself. It was D link Router problem and here is the solution. Hope this helps others.
Check option Clients isolation in Wireless -> Basic.
If it turned ON - clients from LAN wil not access Wi-Fi clients and vice versa.
I have done this successfully before but I am not sure what is going on in this case.
Case that worked:
When I am at home and I connect my computer and my phone to same wifi such that they are on the same network. I can lookup the IP address of my computer and use that IP on my android app to talk to my computer. The local IP is something like 192.168.1.5.
However now I am using a public wifi router. When I connect my computer to wifi I get an IP like 10.10.77.162. When I try to use that IP in my android app to talk to my computer it fails everytime.
What am I doing wrong? Is there an easy way around this?
You have to make sure you forward the port you connect on from your router to your local computer inside your network. Similar to when you open ports for some games such as wow.
Connect your phone the same WiFi network.
Addresses in the 192.168.* and 10.* range aren't globally accessible. They're only used for local networks. If both devices are on the network, they can communicate with each other, but they can't if only one is.
Basically this was due to the fact that I was on a public network in which the router was outside of my control. The router was blocking traffic as one would expect.
Can i interact with a server(android device) from a client(android device) just to query a database located in the server using TCP sockets?
And Yes and No.
If your device is within wireless network and have own local IP. You can connect to it from client phone if it is in the same network just providing proper IP and Port.
If server phone is located in another wireless network, then Port have to be forwarder using router settings to the server port. Bear in mind that if you will reconnect to wireless network by phone, then IP will be automatically assigned by network infrastructure and it might be changed from previous.
If you want to connect to server phone when it is on 3G network (or similar non wifi), you wont have any specific IP, and it is not static, that way it will be almost impossible to create reliable network. It is more Peer-to-Peer model of network you are looking for.
It is much better if you use Server in the middle as Gateway, that way it will be reliable. The only thing is that you will have to host server and its processes with all traffic and so on.
I'm developing client/server software for Android.
While connected to the phone via USB debugging, I'd like to access the webserver I'm running on my developement PC - using the USB connection.
Is that possible and if so, how ?
I stumbled upon the answer after a night sleep.
Enabling USB tethering on my phone (N1, 2.2.1) gives it and the host computer an IP address. The phone can communicate with my web server running on my developement machine!
(Chris, the rumors are right)
Just make sure your web server is listening on that IP address. For apache, use the line
Listen 80
or
Listen x.x.x.x:80
(x.x.x.x being address of your android tunnel)
The easiest way to do it is via wireless. If you don't have wireless, I'd say bite the bullet and get it, it's going to be a necessity for testing anyway :)
Typically the USB only supports connections from the development machine to the phone (via adb port forwards) and not the other way around. Of course once a connection is created data can move bidirectionally. One could use this to build a tunneling proxy web proxy (one connection in from the development machine to a daemon running on the phone, outbound connections from the phone then tunnel through this)
I have heard rumors though that what you want to do - often called reverse tethering - may be supported in some more recent devices.
Kevin's wifi suggestion may be the simplest with a real device.
On the other hand, unlike typical phones, the android emulator can directly access the development machine's loopback interface at an alias address given in the documentation.
I have a Android phone connected with host computer with USB cable. ADB runs well and I can debug application on phone. The only problem is that the App requires special network setup which I can reach on host but not mobile. Is there a way to let the device send all network operations through ADB and Host network?
What you're looking for is known as reverse tethering. See https://android.stackexchange.com/questions/2298/how-to-set-up-reverse-tethering-over-usb for a solution.
Have you tried sharing your internet connection on your laptop, and connect your phone through it?. Make sure you disable data connection on your phone to assure you are connected through WiFi