ADB & Socket分析

确认Socket Server已经开启监听

aven-mac-pro-2:other aven$ adb shell cat /proc/net/unix |less

在列出的所有socket server清单中可以发现,我们新启的@assist_com.wuba.assistant_devtools_remote

Num       RefCount Protocol Flags    Type St Inode Path
00000000: 00000002 00000000 00010000 0001 01 10496 /dev/socket/cnd
00000000: 0000005A 00000000 00000000 0002 01  7179 /dev/socket/logdw
00000000: 00000002 00000000 00010000 0001 01  8198 /dev/socket/property_service
00000000: 00000002 00000000 00010000 0005 01  7182 /dev/socket/logdr
00000000: 00000002 00000000 00010000 0001 01 16293 /data/system/ndebugsocket
00000000: 00000002 00000000 00010000 0001 01  7184 /dev/socket/logd
00000000: 00000002 00000000 00010000 0001 01 9907588 @com.wuba.assistant
00000000: 00000002 00000000 00010000 0001 01 9324308 /dev/socket/adbd
00000000: 00000002 00000000 00010000 0001 01  7192 /dev/socket/cryptd
00000000: 00000003 00000000 00000000 0001 03 10778 /dev/socket/qmux_radio/qmux_client_socket    621
00000000: 00000002 00000000 00010000 0001 01  7195 /dev/socket/vold
00000000: 00000002 00000000 00010000 0001 01 12576 /dev/socket/qmux_radio/qmux_connect_socket
00000000: 00000002 00000000 00010000 0001 01 12578 /dev/socket/qmux_audio/qmux_connect_socket
00000000: 00000002 00000000 00010000 0001 01 9324314 @jdwp-control
00000000: 00000002 00000000 00010000 0001 01 12580 /dev/socket/qmux_bluetooth/qmux_connect_socket
00000000: 00000002 00000000 00010000 0001 01 12582 /dev/socket/qmux_gps/qmux_connect_socket
00000000: 00000003 00000000 00000000 0001 03  7462 /dev/socket/qmux_radio/qmux_client_socket    423
00000000: 00000002 00000000 00010000 0001 01 10556 /data/misc/location/mq/location-mq-s
00000000: 00000003 00000000 00000000 0001 03 14637 /dev/socket/qmux_radio/qmux_client_socket    509
00000000: 00000002 00000000 00010000 0001 01 9909390 @assist_com.wuba.assistant_devtools_remote

下面尝试连接一下这个socket server,由于这个他是运行在手机中的,我们想要在PC上访问的话需要借助adb转发一下,比如: 我们把本地端口9000转发到我们新启的服务;

aven-mac-pro-2:other aven$ adb forward tcp:9000 localabstract:assist_com.wuba.assistant_devtools_remote

接着直接发起一个简单连接请求:

aven-mac-pro-2:other aven$ curl localhost:9000
curl: (52) Empty reply from server

由于我们现在还没有做任何连接反馈,因此在PC端不会收到什么提示,但是在服务端会有日志输出

07-28 16:29:35.721 17481-30828/? I/Assist: accept

在终端内,我们已经验证了socket的联通是良好的,现在我们需要把整个流程写的友好一些;

powered by Gitbook最近更新 2018-09-04

results matching ""

    No results matching ""