SnmpMgrClose function (mgmtapi.h)

[SNMP is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions. Instead, use Windows Remote Management, which is the Microsoft implementation of WS-Man.]

The SnmpMgrClose function closes the communications sockets and data structures that are associated with the specified session. This function is an element of the SNMP Management API.

Syntax

BOOL SNMP_FUNC_TYPE SnmpMgrClose(
  [in] LPSNMP_MGR_SESSION session
);

Parameters

[in] session

Pointer to an internal structure that specifies the session to close. For more information, see the following Remarks section.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

This function may return Windows Sockets error codes.

Remarks

Windows Server 2003:  SNMP manager applications can call SnmpMgrClose with a NULLsession parameter to clean up the resources that are associated with a successful call to the SnmpMgrTrapListen function. Note, however, that if your application is a DLL, it should not call SnmpMgrClose from its DllMain entry-point function.

SnmpMgrClose must not be called when the application DLL is in the process of unloading.

Windows Server 2003:  SnmpMgrClose takes longer to execute under Windows Server 2003 when compared to an identical call under Windows 2000. Specifically, a call to this API takes up to a second to execute under Windows Server 2003, whereas the same call takes around .3 milliseconds under Windows 2000. this may cause performance problems for Windows Server 2003 SNMP applications that call SnmpMgrOpen and SnmpMgrClose frequently.

To address this problem, create an extra SNMP manager session by calling SnmpMgrOpen on the local host during application startup, and keep it open for the duration of the application's lifetime. Closing the session manager will close all associated sessions, requiring only one call to SnmpMgrClose.

Windows Server 2003 with SP1:  The above issue does not apply to Windows 2003 Service Pack 1.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header mgmtapi.h
Library Mgmtapi.lib
DLL Mgmtapi.dll

See also

SNMP Functions

Simple Network Management Protocol (SNMP) Overview

SnmpMgrOpen

SnmpMgrRequest