Platform SDK: Network Management

SnmpClose

The SnmpClose function enables the Microsoft WinSNMP implementation to deallocate memory, resources, and data structures associated with a WinSNMP session. The WinSNMP SnmpClose function also closes communications mechanisms the implementation opened as a result of a call to the SnmpCreateSession function.

SNMPAPI_STATUS SnmpClose(
  HSNMP_SESSION session    // handle to the session to close 
);

Parameters

session
[in] Handle to the WinSNMP session to close.

Return Values

If the function succeeds, the return value is SNMPAPI_SUCCESS.

If the function fails, the return value is SNMPAPI_FAILURE. To get extended error information, call SnmpGetLastError specifying a NULL value in its session parameter. The SnmpGetLastError function can return one of the following errors.

Error Code Description
SNMPAPI_NOT_INITIALIZED The SnmpStartup function did not complete successfully.
SNMPAPI_ALLOC_ERROR An error occurred during memory allocation.
SNMPAPI_SESSION_INVALID The session parameter is invalid.
SNMPAPI_OTHER_ERROR An unknown or undefined error occurred.

Remarks

It is recommended that a WinSNMP application call the SnmpClose function once for each session that the application opened using the SnmpCreateSession function. If a WinSNMP application terminates unexpectedly, it must call SnmpCleanup before it terminates to enable the implementation to deallocate all resources. The implementation processes one SnmpCleanup call as if it were a series of SnmpClose calls, one call for each session opened as a result of a call to SnmpCreateSession.

When the implementation closes a session it discards all outstanding incoming and outgoing asynchronous requests and replies for the session. For additional information, see WinSNMP Sessions.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Winsnmp.h.
  Library: Use Wsnmp32.lib.

See Also

WinSNMP API Overview, WinSNMP Functions, SnmpCleanup, SnmpCreateSession