Thread View: borland.public.cppbuilder.internet.socket
1 messages
1 total messages
Started by jason_zeng
Tue, 24 Aug 2004 11:50
About TIdSNMP question?
Author: jason_zeng
Date: Tue, 24 Aug 2004 11:50
Date: Tue, 24 Aug 2004 11:50
57 lines
2892 bytes
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!
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads