Current location - Quotes Website - Collection of slogans - How to use adb command to forward Android devices
How to use adb command to forward Android devices
The most common way is to use adb command to forward tcp port, such as forwarding TCP port 5039 during gdb debugging. The command is as follows:

$ adb forwards tcp:5039 tcp:5039

If you want to forward device files in Android devices, such as /dev/input/event0, you can do this:

$ ADB forward TCP:800 1 dev:/dev/input/event 0

In this way, you can read and write /dev/input/event0 in Android devices by reading and writing tcp port 800 1 on your computer.

Verification:

You can refer to system/core/libutils/socket _ network _ client.c to quickly create a socket client program:

int FD = socket _ network _ client(" 127 . 0 . 0 . 1 ",800 1,SOCK _ STREAM);

while (true) {

Unsigned character buffer [1024];

int len = recv(fd,buffer, 1024,0);

//Dump buffer information ...

}