GetExtendedTcpTable (Compact 7)
3/12/2014
This function retrieves a table that contains a list of TCP endpoints available to the application.
Syntax
DWORD GetExtendedTcpTable(
__out PVOID pTcpTable,
__inout PDWORD pdwSize,
__in BOOL bOrder,
__in ULONG ulAf,
__in TCP_TABLE_CLASS TableClass,
__in ULONG Reserved
);
Parameters
- pTcpTable
A pointer to the table structure that contains the filtered TCP endpoints available to the application. For information about how to determine the type of table returned based on specific input parameter combinations, see the Remarks section later in this document.
- pdwSize
The estimated size of the structure returned in pTcpTable, in bytes. If this value is set too small, ERROR_INSUFFICIENT_BUFFER is returned by this function, and this field will contain the correct size of the structure.
bOrder
A value that specifies whether the TCP connection table should be sorted. If this parameter is set to TRUE, the TCP endpoints in the table are sorted in ascending order, starting with the lowest local IP address. If this parameter is set to FALSE, the TCP endpoints in the table appear in the order in which they were retrieved.The following values are compared (as listed) when ordering the TCP endpoints:
- Local IP address.
- Local scope ID (applicable when the ulAf parameter is set to AF_INET6).
- Local TCP port.
- Remote IP address.
- Remote scope ID (applicable when the ulAf parameter is set to AF_INET6).
- Remote TCP port.
ulAf
The version of IP used by the TCP endpoints.Value Meaning AF_INET
IPv4 is used.
AF_INET6
IPv6 is used.
TableClass
The type of the TCP table structure to retrieve. This parameter can be one of the values from the TCP_TABLE_CLASS enumeration.The header file organization has changed and the TCP_TABLE_CLASS enumeration is defined in the Iprtrmib.h header file, not in the Iphlpapi.h header file.
The TCP_TABLE_CLASS enumeration value is combined with the value of the ulAf parameter to determine the extended TCP information to retrieve.
- Reserved
Reserved. This value must be zero.
Return Value
Return code | Description |
---|---|
NO_ERROR |
The call is successful. |
ERROR_INSUFFICIENT_BUFFER |
An insufficient amount of space was allocated for the table. The size of the table is returned in the pdwSize parameter, and must be used in a subsequent call to this function in order to successfully retrieve the table. This error is also returned if the pTcpTable parameter is NULL. |
ERROR_INVALID_PARAMETER |
An invalid parameter was passed to the function. This error is returned if the TableClass parameter contains a value that is not defined in the TCP_TABLE_CLASS enumeration. |
Remarks
The table type returned by this function depends on the specific combination of the ulAf parameter and the TableClass parameter.
When the ulAf parameter is set to AF_INET, the following table indicates the TCP table type to retrieve in the structure pointed to by the pTcpTable parameter for each possible TableClass value.
TableClassvalue | pTcpTablestructure |
---|---|
TCP_TABLE_BASIC_ALL |
|
TCP_TABLE_BASIC_CONNECTIONS |
MIB_TCPTABLE |
TCP_TABLE_BASIC_LISTENER |
MIB_TCPTABLE |
TCP_TABLE_OWNER_MODULE_ALL |
|
TCP_TABLE_OWNER_MODULE_CONNECTIONS |
MIB_TCPTABLE_OWNER_MODULE |
TCP_TABLE_OWNER_MODULE_LISTENER |
MIB_TCPTABLE_OWNER_MODULE |
TCP_TABLE_OWNER_PID_ALL |
|
TCP_TABLE_OWNER_PID_CONNECTIONS |
MIB_TCPTABLE_OWNER_PID |
TCP_TABLE_OWNER_PID_LISTENER |
MIB_TCPTABLE_OWNER_PID |
When the ulAf parameter is set to AF_INET6, the following table indicates the TCP table type to retrieve in the structure pointed to by the pTcpTable parameter for each possible TableClass value.
TableClassvalue | pTcpTablestructure |
---|---|
TCP_TABLE_BASIC_ALL |
|
TCP_TABLE_BASIC_CONNECTIONS |
MIB_TCP6TABLE |
TCP_TABLE_BASIC_LISTENER |
MIB_TCP6TABLE |
TCP_TABLE_OWNER_MODULE_ALL |
|
TCP_TABLE_OWNER_MODULE_CONNECTIONS |
MIB_TCP6TABLE_OWNER_MODULE |
TCP_TABLE_OWNER_MODULE_LISTENER |
MIB_TCP6TABLE_OWNER_MODULE |
TCP_TABLE_OWNER_PID_ALL |
|
TCP_TABLE_OWNER_PID_CONNECTIONS |
MIB_TCP6TABLE_OWNER_PID |
TCP_TABLE_OWNER_PID_LISTENER |
MIB_TCP6TABLE_OWNER_PID |
The header file organization has changed. The various MIB_TCPTABLE structures are defined in the Tcpmib.h header file instead of in the Iprtrmib.h header file. Notice that the Tcpmib.h header file is automatically included in Iprtrmib.h, which is automatically included in the Iphlpapi.h header file. The Tcpmib.h and Iprtrmib.h header files should never be used directly.
See Also
Reference
IP Helper Functions
MIB_TCP6TABLE
MIB_TCP6TABLE_OWNER_MODULE
MIB_TCP6TABLE_OWNER_PID
MIB_TCPTABLE
MIB_TCPTABLE_OWNER_MODULE
MIB_TCPTABLE_OWNER_PID
TCP_TABLE_CLASS