各位前辈,偶刚刚开始接触SNMP++。根据例程改写的接收程序如下: 
我的问题是为什么当有trap来时,程序的回调函数没有反应。而同样的程序在MFC界面下却可以接收到???
/*#include "eventlist.h"   // needed for my own main loop*/
#include "StdAfx.h"
#include ".\include\snmp_pp.h"
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
// trap function callback
void trap_callback( int reason,
                    Snmp *session,
                    Pdu &pdu,
                    SnmpTarget &target,
                    void *cbd) 
{
  char outbuff[1024];
  char scratch[256];
  GenAddress address;
  Oid trapid;
  Vb vb;
  TimeTicks timestamp;  if ( reason == SNMP_CLASS_NOTIFICATION) {
     target.get_address( address);
         pdu.get_notify_id( trapid);
         pdu.get_notify_timestamp( timestamp);
         strcpy( outbuff,"Trap From:");
         strcat( outbuff, address.get_printable());
         strcat( outbuff, "\n");
         strcat( outbuff, "Trap ID:");
         strcat( outbuff, trapid.get_printable());
         strcat( outbuff, "\n");
         strcat( outbuff, "Trap Time:");
         strcat( outbuff, timestamp.get_printable());
         strcat( outbuff, "\n");
         for( int z=0;z<pdu.get_vb_count();z++) {
            strcat( outbuff,"Vb# ");
                sprintf( scratch,"%d",z+1);
                strcat( outbuff, scratch);
                strcat( outbuff, "\n");
                pdu.get_vb(vb,z);
                sprintf( scratch,"Oid = %s\nValue= %s\n", vb.get_printable_oid(), vb.get_printable_value());
                strcat( outbuff, scratch);
     }
     printf(outbuff);
  }};int main( )  {   int maxfds;
   fd_set readfds, writefds, exceptfds;
   TargetCollection targets;
   OidCollection oids;     //----------[ create a SNMP++ session ]-----------------------------------
   int status; 
   Snmp snmp( status);                // check construction status
   if ( status != SNMP_CLASS_SUCCESS) {
      cout << "SNMP++ Session Create Fail, " << snmp.error_msg(status) << "\n";
      return 0;
   }   //----------[ register to receive traps ]---------------------------------
   status = snmp.notify_register( oids, targets, &trap_callback, NULL);
   if ( status != SNMP_CLASS_SUCCESS) {
      cout << "SNMP++ Session Create Fail, " << snmp.error_msg(status) << "\n";
      return 0;
   }   //---------[ set up the select loop ]-------------------------------------
   /*SNMPGetFdSets(maxfds, readfds, writefds, exceptfds);
   for (;;) {
      select( maxfds, &readfds, & writefds, &exceptfds,NULL);
      Sleep(100);
      SNMPProcessPendingEvents();
   };*/
   while(1)
   {
   }
   return 0;}  // end get