当前的HTTP服务器在监听哪些端口?

人工智能 2026-07-08

我在创建一个REST API服务器。

我是通过拿一些旧代码来实现这一点,这些代码基于 cgi-binext-cgi,因此下面的请求得到了正确处理:

http://localhost:3003/cgi-bin/ext.cgi?GetInformationMethod?Type=2304

当我尝试使用另一种方法并带上更多参数时失败了,于是我决定检查TCP端口是否仍在监听状态。令我惊讶的是,得到的响应是:

Prompt>netstat -aon | findstr "3003"
  TCP    0.0.0.0:3003           0.0.0.0:0              LISTENING       5776
  TCP    0.0.0.0:3003           0.0.0.0:0              LISTENING       11912
  TCP    0.0.0.0:3003           0.0.0.0:0              LISTENING       11480
  TCP    0.0.0.0:3003           0.0.0.0:0              LISTENING       6600
  TCP    0.0.0.0:3003           0.0.0.0:0              LISTENING       11016
  TCP    0.0.0.0:3003           0.0.0.0:0              LISTENING       2516

查询那些进程的名称时,得到的是(PowerShell):

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    522      55    16856      51608       0.89  11016   0 App1
    625      64    17140      59408       5.83   6600   0 App2
    644      68    22556     170620      23.61   2516   0 My_Application
    578      63    19972      63092       8.27  11480   0 App3
    796      79    49220     169384      25.98   5776   0 App4
    612      64    23416      67532      11.59  11912   0 App5

这让我觉得,要么是:

  • 存在多个HTTP服务器,每个服务器都有自己的 "endpoint";或者
  • 只有一个HTTP服务器,但被HTTP请求使用的 "endpoint" 决定将处理该HTTP请求的应用程序。

不管是哪种情况,应该有一个“HTTP请求模板/端点”与应用之间的联系,类似于:

App1              template/endpoint for App1
App2              template/endpoint for App2
My_Application    ±cgi-bin ... ext.cgi
App3              template/endpoint for App3
App4              template/endpoint for App4
App5              template/endpoint for App5

有人知道实现这个的Windows命令行命令吗?

我一直在向一个AI机器人提问,但它只说HTTP请求的处理是在应用程序内部决定的。我当然知道这一点,但我想应该有一种方式(希望可以通过命令行确定),来判断哪种HTTP请求“风格”由哪个应用程序处理。

netsh http show的结果:

Prompt>netsh http show servicestate

Snapshot of HTTP service state (Server Session View):
-----------------------------------------------------

Server session ID: FF00000010000001
    Version: 2.0
    State: Active
    Properties:
        Max bandwidth: 4294967295
        Timeouts:
            Entity body timeout (secs): 120
            Drain entity body timeout (secs): 120
            Request queue timeout (secs): 65535
            Idle connection timeout (secs): 120
            Header wait timeout (secs): 120
            Minimum send rate (bytes/sec): 240
    URL groups:
    URL group ID: FF00000120000001
        State: Active
        Request queue name: DefaultAppPool
        Properties:
            Max bandwidth: inherited
            Max connections: 4294967295
            Timeouts:
                Entity body timeout (secs): 120
                Drain entity body timeout (secs): 120
                Request queue timeout (secs): 65535
                Idle connection timeout (secs): 120
                Header wait timeout (secs): 0
                Minimum send rate (bytes/sec): 0
            Logging information:
                Log directory: C:\inetpub\logs\LogFiles\W3SVC1
                Log format: 0
            Authentication Configuration:
                Authentication schemes enabled:
            Number of registered URLs: 1
            Registered URLs:
                HTTP://*:80/
    URL group ID: FF00000530000001
        State: Active
        Request queue name: EA-Pool
        Properties:
            Max bandwidth: inherited
            Max connections: inherited
            Timeouts:
                Timeout values inherited
            Authentication Configuration:
                Authentication schemes enabled:
            Number of registered URLs: 1
            Registered URLs:
                HTTP://*:80/EA-HELP/
    URL group ID: FE00000180000001
        State: Active
        Request queue name: EA-Pool
        Properties:
            Max bandwidth: inherited
            Max connections: inherited
            Timeouts:
                Timeout values inherited
            Authentication Configuration:
                Authentication schemes enabled:
            Number of registered URLs: 1
            Registered URLs:
                HTTP://*:80/EA/

Server session ID: FF00000460000001
    Version: 1.0
    State: Active
    Properties:
        Max bandwidth: 4294967295
        Timeouts:
            Entity body timeout (secs): 120
            Drain entity body timeout (secs): 120
            Request queue timeout (secs): 120
            Idle connection timeout (secs): 120
            Header wait timeout (secs): 120
            Minimum send rate (bytes/sec): 150
    URL groups:
    URL group ID: FE00000460000001
        State: Active
        Request queue name: Request queue is unnamed.
        Properties:
            Max bandwidth: inherited
            Max connections: inherited
            Timeouts:
                Timeout values inherited
            Number of registered URLs: 2
            Registered URLs:
                HTTP://+:5985/WSMAN/
                HTTP://+:47001/WSMAN/

Request queues:
    Request queue name: Request queue is unnamed.
        Version: 1.0
        State: Active
        Request queue 503 verbosity level: Basic
        Max requests: 1000
        Active requests: 0
        Queued requests: 0
        Max queued request age: 0s
        Requests arrived: 0
        Requests rejected: 0
        Cache hits: 0
        Number of active processes attached: 1
        Processes:
            ID: 3868, image: C:\Windows\System32\svchost.exe
            Services: WinRM
            Tagged Service: WinRM
        Registered URLs:
            HTTP://+:5985/WSMAN/
            HTTP://+:47001/WSMAN/

    Request queue name: DefaultAppPool
        Security descriptor: O:BAG:SYD:AI(A;;FR;;;S-1-5-82-<some_GUID>)(A;;FA;;;SY)
        Version: 2.0
        State: Active
        Request queue 503 verbosity level: Limited
        Max requests: 1000
        Active requests: 0
        Queued requests: 0
        Max queued request age: 0s
        Requests arrived: 0
        Requests rejected: 0
        Cache hits: 0
        Number of active processes attached: 0
        Controller process:
            ID: 3856, image: C:\Windows\System32\svchost.exe
            Services: WAS, W3SVC
            Tagged Service: WAS
        Processes:
        Registered URLs:
            HTTP://*:80/

    Request queue name: EA-Pool
        Security descriptor: O:BAG:SYD:AI(A;;FR;;;S-1-5-82-<some_other_GUID>)(A;;FA;;;SY)
        Version: 2.0
        State: Active
        Request queue 503 verbosity level: Limited
        Max requests: 4000
        Active requests: 0
        Queued requests: 0
        Max queued request age: 0s
        Requests arrived: 0
        Requests rejected: 0
        Cache hits: 0
        Number of active processes attached: 0
        Controller process:
            ID: 3856, image: C:\Windows\System32\svchost.exe
            Services: WAS, W3SVC
            Tagged Service: WAS
        Processes:
        Registered URLs:
            HTTP://*:80/EA/
            HTTP://*:80/EA-HELP/

解决方案

在此期间,我已经解决了问题:我确实有几个HTTP服务器彼此并排运行,造成了我发送的HTTP请求混乱,但这并不是因为这些请求本身已经存在,而是因为我在一个被六个不同应用程序加载的DLL中创建并启动了这些HTTP服务器所致!

我已经确保HTTP服务器只会被创建并启动一次,现在再也没有前面提到的问题了。

站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章