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!
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.
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.
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.
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:
list-forward
forward:<local>;<remote>
forward:norebind:<local>;<remote>
killforward-all
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 justhost
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With