Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb forward remote port to local machine

This is a query regarding the usage of adb on android.

Is there a way to forward the remote port i.e. port on the android device/emulator to the local machine to which the device is connected?

$ adb forward tcp:port1 tcp:port2 # forwards the local port port1 on the machine to port2 on the device.

Thanks in advance!

like image 288
Gaurav Khurana Avatar asked Aug 05 '10 14:08

Gaurav Khurana


People also ask

How does adb forward work?

Basically means that the requests on specific port on the host will be forwarded to a specific port on the device. Where the first port is the host and the second one is the device port.

What is adb port forwarding?

I'm developing an Android app as a side project and today I learned about adb forward and adb reverse . Basically, they allow you to forward or reverse traffic to specific ports between an Android device and your development machine.

How do I use remote adb shell?

To connect to your remote Android device, type in the IP address of the device and the port number (5555 from the example above) in Remote ADB Shell. Tap Connect and it will attempt to connect to the device and start up the terminal.


1 Answers

Recently google updated ADB service. And added reverse command that should do the job.

From reverse documentation:

This implements the adb reverse feature, i.e. the ability to reverse socket connections from a device to the host. <forward-command> is one of the forwarding commands that are described above, as in:

  1. list-forward
  2. forward:<local>;<remote>
  3. forward:norebind:<local>;<remote>
  4. killforward-all
  5. killforward:<local>

Note that in this case, <local> corresponds to the socket on the device and <remote> corresponds to the socket on the host.

The output of reverse:list-forward is the same as host:list-forward except that <serial> will be just host.

like image 128
molokoka Avatar answered Oct 17 '22 15:10

molokoka