How to use ADB shell to find the ports which a process is using?

守給你的承諾、 提交于 2019-12-09 05:34:57

问题


For example, in Android, the PID of a process 1234 is using ports 2222,2223,2224. Now I have a PID 1234. I was wondering how to find out port numbers 2222, 2223, 2224 which the process is using?

I have tried using netstat -anp just as the way in Linux, but that didn't work. netstat -anp in ADB shell has the same effect as just netstat, which is without any command arguments.


回答1:


You can either use busybox netstat -pt or cat /proc/1234/net/tcp




回答2:


Try to check my github repository, https://github.com/LipiLee/netstat.

I updated toolbox's netstat in Android source code(https://android.googlesource.com/platform/system/core/+/master/toolbox/netstat.c).

UPDATE: The toolbox's netstat was replaced with toybox's netstat in Android M version. So the netstat in toolbox was removed in the Android source tree.



来源:https://stackoverflow.com/questions/14229816/how-to-use-adb-shell-to-find-the-ports-which-a-process-is-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!