获取系统系统所有TCP以及UDP端口使用情况

GetTcpTable

<script src="../langref.js"></script>

GetTcpTable

The GetTcpTable function retrieves the TCP connection table.

DWORD
 GetTcpTable(

  PMIB_TCPTABLE
 pTcpTable

,
  // buffer for the connection table
  PDWORD
 pdwSize

,
           // size of the buffer
  BOOL
 bOrder

               // sort the table?
);
Parameters
pTcpTable
[out] Pointer to a buffer that receives the TCP connection table as a MIB_TCPTABLE structure.
pdwSize
[in, out] On input, specifies the size of the buffer pointed to by the pTcpTable parameter.

On output, if the buffer is not large enough to hold the returned connection table, the function sets this parameter equal to the required buffer size.

bOrder
[in] Specifies whether the connection table should be sorted. If this parameter is TRUE, the table is sorted in the order of:
  1. Local IP address
  2. Local port
  3. Remote IP address
  4. Remote port
Return Values

If the function succeeds, the return value is NO_ERROR.

If the function fails, use FormatMessage to obtain the message string for the returned error.

Requirements

  Windows NT/2000 or later: Requires Windows NT 4.0 SP4 or later.
  Windows 95/98/Me: Requires Windows 98 or later.
  Header: Declared in Iphlpapi.h.
  Library: Use Iphlpapi.lib.

 

 

MIB_TCPTABLE <script src="../langref.js"></script>

MIB_TCPTABLE

The MIB_TCPTABLE structure contains a table of TCP connections.

typedef struct _MIB_TCPTABLE {
  DWORD      dwNumEntries
;    // number of entries in the table 
  MIB_TCPROW table
[ANY_SIZE]; // array of TCP connections 
} MIB_TCPTABLE, *PMIB_TCPTABLE;
Members
dwNumEntries
Specifies the number of entries in the table.
table[ANY_SIZE]
Pointer to a table of TCP connections implemented as an array of MIB_TCPROW structures.


MIB_TCPROW <script src="../langref.js"></script>

MIB_TCPROW

The MIB_TCPROW structure contains information for a TCP connection.

typedef struct _MIB_TCPROW {
  DWORD   dwState
;        // state of the connection
  DWORD   dwLocalAddr
;    // address on local computer
  DWORD   dwLocalPort
;    // port number on local computer
  DWORD   dwRemoteAddr
;   // address on remote computer
  DWORD   dwRemotePort
;   // port number on remote computer
} MIB_TCPROW, *PMIB_TCPROW;
Members
dwState
Specifies the state of the TCP connection. This member can have one of the following values.
ValueDescription
MIB_TCP_STATE_CLOSEDTo be determined.
MIB_TCP_STATE_LISTENTo be determined.
MIB_TCP_STATE_SYN_SENTTo be determined.
MIB_TCP_STATE_SYN_RCVDTo be determined.
MIB_TCP_STATE_ESTABTo be determined.
MIB_TCP_STATE_FIN_WAIT1To be determined.
MIB_TCP_STATE_FIN_WAIT2To be determined.
MIB_TCP_STATE_CLOSE_WAITTo be determined.
MIB_TCP_STATE_CLOSINGTo be determined.
MIB_TCP_STATE_LAST_ACKTo be determined.
MIB_TCP_STATE_TIME_WAITTo be determined.
MIB_TCP_STATE_DELETE_TCBTransmission Control Block (TCB) deleted.

dwLocalAddr
Specifies the address for the connection on the local computer.
dwLocalPort
Specifies the port number for the connection on the local computer.
dwRemoteAddr
Specifies the address for the connection on the remote computer.
dwRemotePort
Specifies the port number the connection on the remote computer.


GetUdpTable

<script src="../langref.js"></script>

GetUdpTable

The GetUdpTable function retrieves the User Datagram Protocol (UDP) listener table.

DWORD
 GetUdpTable(

  PMIB_UDPTABLE
 pUdpTable

,
  // buffer for the listener table 
  PDWORD
 pdwSize

,
           // size of buffer
  BOOL
 bOrder

               // sort the table?
);
Parameters
pUdpTable
[out] Pointer to a buffer that receives the UDP listener table as a MIB_UDPTABLE structure.
pdwSize
[in, out] On input, specifies the size of the buffer pointed to by the pUdpTable parameter.

On output, if the buffer is not large enough to hold the returned listener table, the function sets this parameter equal to the required buffer size.

bOrder
[in] Specifies whether the returned table should be sorted. If this parameter is TRUE, the table is sorted in the order of:
  1. IP address
  2. Port
Return Values

If the function succeeds, the return value is NO_ERROR.

If the function fails, use FormatMessage to obtain the message string for the returned error.

Requirements

  Windows NT/2000 or later: Requires Windows NT 4.0 SP4 or later.
  Windows 95/98/Me: Requires Windows 98 or later.
  Header: Declared in Iphlpapi.h.
  Library: Use Iphlpapi.lib.

 

MIB_UDPTABLE <script src="../langref.js"></script>

MIB_UDPTABLE

The MIB_UDPTABLE structure contains a table of MIB_UDPROW structures.

typedef struct _MIB_UDPTABLE {
  DWORD       dwNumEntries
;    // number of entries in the table
  MIB_UDPROW  table
[ANY_SIZE]; // table of MIB_UDPROW structs
} MIB_UDPTABLE, *PMIB_UDPTABLE;
Members
dwNumEntries
Specifies the number of entries in the table.
table[ANY_SIZE]
Pointer to an array of MIB_UDPROW structures.


MIB_UDPROW <script src="../langref.js"></script>

MIB_UDPROW

The MIB_UDPROW structure contains address information for sending and receiving User Datagram Protocol (UDP) datagrams.

typedef struct _MIB_UDPROW {
  DWORD   dwLocalAddr
;    // IP address on local computer
  DWORD   dwLocalPort
;    // port number on local computer
} MIB_UDPROW, *PMIB_UDPROW;
Members
dwLocalAddr
Specifies the IP address on the local computer.
dwLocalPort
Specifies the port number on the local computer.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值