please dont rip this site Prev Next

SnmpMgrTrapListen info  Overview  Group

The SnmpMgrTrapListen function registers the ability of a manager application to receive SNMP traps.

BOOL SnmpMgrTrapListen(

    HANDLE *phTrapAvailable

// event handle indicating trap(s) available



[out] Points to an event handle that will be used to indicate 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



Indicates a memory allocation error.


Indicates that this function has already been called.


Indicates an error occurred; the application can attempt to call the function again.

This function may return other system errors as well.


It is important to note that the SnmpMgrTrapListen function succeeds on Windows NT 4.0 only if the SNMP Trap Service has been started. See Turning SNMP On and Off for additional information.

The event that the phTrapAvailable parameter points to allows event-driven acquisition of SNMP traps. If you call the SnmpMgrTrapListen function first, you can ignore the event handle and poll the SnmpMgrGetTrap function for traps at regular intervals instead.

Another method to acquire traps is to create a thread to wait on the event using the WaitForSingleObject function. When the call initiates an event, the thread should clear the event using the ResetEvent function. Then the thread should repeatedly call the SnmpMgrGetTrap function until it returns zero.

Always call the SnmpMgrTrapListen function before calling SnmpMgrGetTrap to receive traps. If an SNMP manager application calls SnmpMgrGetTrap first to receive traps, it returns zero, even if there are traps available. If the application calls GetLastError before calling SnmpMgrTrapListen, GetLastError returns the error code SNMP_MGMTAPI_TRAP_ERRORS.

See Also

SnmpMgrGetTrap, WaitForSingleObject, ResetEvent

See also:

file: /Techref/os/win/api/win32/func/src/f86_7.htm, 4KB, , updated: 2000/4/7 12:19, local time: 2022/5/23 17:11,

 ©2022 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> SnmpMgrTrapListen</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2022 contributors:
o List host: MIT, Site host, Top posters @20220523
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!