Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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 ?

share|improve this question
up vote 2 down vote accepted

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)

share|improve this answer
    
but can you debug while your tethering is active? this does not seem to be the case for me(galaxy s running 2.3.3). – Tjaart Sep 5 '12 at 8:35
    
It's been a while since so I don't remember @Tjaart. I don't remember any problems though, and It's likely that I was using the debugger. I can't see why it wouldn't work. – olafure Sep 18 '12 at 13:37
    
its working now. I cant remember what exactly was wrong. – Tjaart Sep 19 '12 at 7:44

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 :)

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.