查看 netstat 显示的结果时,“Listening”指的是什么?

查看 netstat 显示的结果时,“Listening”指的是什么?

例如,当我查看 PC 的 netstat 结果时,我很难理解“正在监听”是什么意思。这是否意味着我有一个应用程序或服务正在等待请求?

答案1

使用-bWindowsnetstat命令中的选项来显示正在监听的程序

  -a            Displays all connections and listening ports.
  -b            Displays the executable involved in creating each connection or
                listening port. In some cases well-known executables host
                multiple independent components, and in these cases the
                sequence of components involved in creating the connection
                or listening port is displayed. In this case the executable
                name is in [] at the bottom, on top is the component it called,
                and so forth until TCP/IP was reached. Note that this option
                can be time-consuming and will fail unless you have sufficient
                permissions.

通常,只有服务器类型的应用程序才会监听传入连接。但是,Windows 也有监听 NETBIOS 广播和其他类型的 MS 网络聊天的服务。

C:\> netstat -ab

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    Boxname:http           Boxname:0              LISTENING       1708
  [Apache]

  TCP    Boxname:netbios-ssn    Boxname:0              LISTENING       4
  [System]

答案2

或多或少,假设服务器必须先监听端口才能执行任何操作。因此,Web 服务器将监听端口 80 以获取请求,然后提供页面。

相关内容