【问题标题】:How to use ADB shell to find the ports which a process is using?如何使用 ADB shell 查找进程正在使用的端口?
【发布时间】:2012-12-23 04:21:09
【问题描述】:

例如,在 Android 中,进程 1234 的 PID 使用端口 2222,2223,2224。现在我有一个 PID 1234。我想知道如何找出进程正在使用的端口号 2222、2223、2224?

我曾尝试像在 Linux 中那样使用 netstat -anp,但没有奏效。 ADB shell 中的 netstat -anp 与 netstat 的效果相同,没有任何命令参数。

【问题讨论】:

标签: android linux port adb netstat


【解决方案1】:

您可以使用busybox netstat -ptcat /proc/1234/net/tcp

【讨论】:

  • 假设安装了busybox。
  • @Alex cat /proc/1234/net/tcp 列出系统上的所有 tcp 套接字,而不仅仅是进程 1234 打开的套接字。
【解决方案2】:

尝试检查我的 github 存储库,https://github.com/LipiLee/netstat

我在 Android 源代码中更新了工具箱的 netstat(https://android.googlesource.com/platform/system/core/+/master/toolbox/netstat.c)。

更新:在 Android M 版本中,工具箱的 netstat 已替换为 toybox 的 netstat。所以工具箱中的 netstat 在 Android 源码树中被移除了。

【讨论】:

    猜你喜欢
    • 2018-12-27
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    • 2018-10-05
    • 2013-04-03
    • 2013-07-30
    • 2023-01-21
    相关资源
    最近更新 更多