Platform SDK: Network Management

SnmpMgrTrapListen

The SnmpMgrTrapListen function registers the ability of an SNMP manager application to receive SNMP traps from the SNMP Trap Service. This function is an element of the SNMP Management API.

BOOL SnmpMgrTrapListen(
  HANDLE *phTrapAvailable  // event handle indicating a trap 
                           //  is available
);

Parameters

phTrapAvailable
[out] Pointer to an event handle to receive an indication that there are traps available, and that the application should call the SnmpMgrGetTrap function.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return any of the following error codes.

Error Code Description
SNMP_MEM_ALLOC_ERROR Indicates a memory allocation error.
SNMP_MGMTAPI_TRAP_DUPINIT Indicates that this function has already been called.
SNMP_MGMTAPI_AGAIN Indicates an error occurred; the application can attempt to call the function again.

This function may return other system errors as well.

Remarks

It is important to note that the SnmpMgrTrapListen function succeeds on Windows NT® 4.0 and Windows® 2000 only if the SNMP trap service has been started.

The application must always call the SnmpMgrTrapListen function before calling the SnmpMgrGetTrap function. This is because the event handle pointed to by the phTrapAvailable parameter enables the event-driven acquisition of SNMP traps. The SNMP Management API signals an application's event when the SNMP Trap Service delivers a trap.

The application can also poll the SnmpMgrGetTrap function for traps at regular intervals. In this case, the application should repeatedly call SnmpMgrGetTrap until the function returns zero.

Requirements

  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Unsupported.
  Header: Declared in Mgmtapi.h.
  Library: Use Mgmtapi.lib.

See Also

Simple Network Management Protocol (SNMP) Overview, SNMP Functions, SnmpMgrGetTrap