Forward example
Forwarding can be done with command adb forward
tcp:<localport> tcp:<remoteport>
. This is not
overly documented. The idea is that the adb daemon will listen on
tcp port <localport> on your PC, and when a connection comes
in, it will re-recreate the session on the Android using tcp port
<remoteport>. Usage example:
PC: adb tcp:1111 tcp:1112
PC: adb shell
Android: nc -l -p 1112
(in another shell session)
PC: echo Just testing | nc 127.0.0.1 1111
Now, you will see 'Just testing' be echoed, demonstrating the
existance of a working tunnel. Obviously, this also functions the
other way round:
PC: adb tcp:1111 tcp:1112
PCL adb shell
Android: echo Just testing' | nc -l -p 1112
(in another shell session)
PC: nc 127.0.0.1 1111
Btw, the PC tcp port <localport> listens on localhost only.
On the Android device, no port is created, but an application
should (going to) be listening on the <remoteport>. And: the
basic idea is that you need a listening app on the Android device,
and a sending app on the PC.