🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #5375

About TIdSNMP question?

#5375
From: jason_zeng
Date: Tue, 24 Aug 2004 11:50
57 lines
2892 bytes
I meet to some trouble when I use TIdSNMP by C++Builder5,Win2000. I use one
TNMUDP component,one ListItem component and one TIdSNMP component in a
form,the TNMUDP port property was set to 162 to receive UDP data.In TNMUDP
OnDataReceived event,the programm is as below:



void __fastcall TForm1::NMUDPDataReceived(TComponent *Sender,
      int NumberBytes, AnsiString FromIP, int Port)
{

     IdSNMP->TrapPort = 162;
     IdSNMP->ReceiveTimeout = 200;
     IdSNMP->Host = "192.168.68.16";
     IdSNMP->Community = "public";
     IdSNMP->Active = true;
 //    IdSNMP->Trap->Clear();

//     ListItem->Caption =  FromIP;
       char *buf = new char[NumberBytes];
       int Length;
       NMUDP->ReadBuffer(buf,NumberBytes,Length);   // here:read buffer to
receive trap
       IdSNMP->Trap->Buffer = AnsiString(buf);

       IdSNMP->Trap->DecodeTrap(); //  here:the programm have no response
when debugger trace
       TListItem *ListItem ;       //  to here
       ListItem = ListView->Items->Add();
       ListItem->Caption = FromIP;
       if ( IdSNMP->Trap->Enterprise == "1.3.6.1.4.1.17409.1.0" )
            {
              if (IdSNMP->Trap->GenTrap == 6 )
                switch( IdSNMP->Trap->SpecTrap )
                {
                  case 0: ListItem->SubItems->Add("hfcColdStart");
                          ListItem->SubItems->Add(FormatDateTime("yyyy-mm-dd
hh:mm",Now()));
                          break;
                  case 1: ListItem->SubItems->Add("AlarmEvent");
                          ListItem->SubItems->Add(FormatDateTime("yyyy-mm-dd
hh:mm",Now()));
                          break;
                  case 2: ListItem->SubItems->Add("hfcWarmStart");
                          ListItem->SubItems->Add(FormatDateTime("yyyy-mm-dd
hh:mm",Now()));
                          break;

                }
            }


 }

By the way,I have also try to use ReceiveTrap() method,But it have the same
question that the program have no response,How can I do this, please help me
,thank you very much!
Technical Details
Message-ID: <412b2edd@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,f709ff4c8bc782a5,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "jason_zeng" <jie_zeng@photontec.com>
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: About TIdSNMP question?
Date: Tue, 24 Aug 2004 19:50:58 +0800
Lines: 60
Organization: photon
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 202.105.138.126
Message-ID: <412b2edd@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1093349085 202.105.138.126 (24 Aug 2004 05:04:45 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail