Opening and Closing a WinSNMP Session

[This is preliminary documentation and subject to change.]

To open a session, a manager application calls the SnmpOpen function. If the function completes successfully, the Microsoft WinSNMP implementation opens a session, and the function returns a session identifier in the form of an HSNMP_SESSION handle. All WinSNMP functions that return handle variables include the session identifier as an input parameter. This enables the implementation to use the handle to efficiently manage resources at the session level.

An application can have multiple sessions open at one time. Multiple sessions within an application can share handle variables.

If the implementation cannot open a session because of resource limitations, it returns SNMPAPI_FAILURE when the application calls SnmpOpen. If the application then calls the SnmpGetLastError function, it returns SNMPAPI_ALLOC_ERROR.

A call to the SnmpClose function enables the implementation to free any remaining resources and to close the session.

For additional information, see Resource Handle Objects and WinSNMP Sessions.