Skip to content

IPGlobalProperties throws generic Exception on 'high load' error code from WinAPI GetTcpTable() #29560

Description

@dbeinder

When the Windows TCP connections table changes rapidly, the Windows API call GetTcpTable can return STATUS_UNSUCCESSFUL (0xc0000001). This return value is currently used by .NET to throw a generic NetworkInformationException which, when printed, only displays Unknown error (0xc0000001).

GetTcpTable is used internally by .NET in the System.Net assembly:
IPGlobalProperties.GetActiveTcpConnections()
IPGlobalProperties.GetActiveTcpListeners()

The WinAPI documentation for GetTcpTable is short on guarantees, but recommends simply repeating the call.
Can someone with deeper knowledge of the Windows API comment if it would be safe for .NET to retry until the call succeeds?
If that risks major lock-ups, NetworkInformationException should be extended to give users a flag to allow them to implement their own retry logic. For now, this can be done by checking the ErrorCode of the exception manually against against 0xc0000001.

The same issue exists in .NET Core and .NET Framework, since the code is virtually identical.

Curiously, the WinApi documentation does not mention this behaviour for similar calls, like GetExtendedTcpTable, GetUdpTable, GetExtendedUdpTable which are also used by .NET - again, it would be great to know if these functions are safe, or if it is simply an oversight in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions