Finding TCP ports used by application

前端 未结 3 2146
刺人心
刺人心 2020-12-16 21:30

All right, so I\'m extending my company\'s flexlm vendor daemon to be a little bit more revealing to client applications.

I need to be able to find out what port lmg

3条回答
  •  被撕碎了的回忆
    2020-12-16 21:56

    GetTcpTable2 -- see below

    GetTcpTable2 function

    The GetTcpTable function retrieves the IPv4 TCP connection table.

    This will fill in a MIB_TCPTABLE structure.

    typedef struct _MIB_TCPTABLE {
      DWORD      dwNumEntries;
      MIB_TCPROW table[ANY_SIZE];
    } MIB_TCPTABLE, *PMIB_TCPTABLE;
    

    And now the MIB_TCPROW

    typedef struct _MIB_TCPROW {
      DWORD dwState;
      DWORD dwLocalAddr;
      DWORD dwLocalPort;
      DWORD dwRemoteAddr;
      DWORD dwRemotePort;
    } MIB_TCPROW, *PMIB_TCPROW;
    

    IMPORTANT:

    You need to use GetTcpTable2 in order to get the corresponding PID associated as well.

    typedef struct _MIB_TCPROW2 {
      DWORD                        dwState;
      DWORD                        dwLocalAddr;
      DWORD                        dwLocalPort;
      DWORD                        dwRemoteAddr;
      DWORD                        dwRemotePort;
      DWORD                        dwOwningPid;
      TCP_CONNECTION_OFFLOAD_STATE dwOffloadState;
    } MIB_TCPROW2, *PMIB_TCPROW2;
    

    dwOwningPid

提交回复
热议问题