GXSNMP component sends received data through this method.
Note: Do not modify the received data packet.
Note: Do not modify the received data packet.
- sender (Object)
- The source of the event.
- packet (GXSNMPPacket)
- GXSNMPPacket containing the received data.
- senderInfo (String)
- Sender network address and port number.
/// <summary>
/// Show received data.
/// </summary>
/// <param name="sender"></param>
/// <param name="SNMPPacket"></param>
/// <param name="SenderInfo"></param>
private void gxsnmp1_OnReceived(object sender, Gurux.SNMP.GXSNMPPacket SNMPPacket, string SenderInfo)
{
try
{
if (SNMPPacket.ErrorIndex != 0)
{
MessageBox.Show(SNMPPacket.ErrorStatusAsString);
return;
}
foreach (Gurux.SNMP.GXSNMPDataItem it in SNMPPacket.DataItems)
{
OIDList.Items.Add(it.OID + ": " + System.Convert.ToString(it.Data));
}
Label4.Text = OIDList.Items.Count.ToString();
if (bWalk)
{
if (!SNMPPacket.IsWalkFinish) //If walk loop throw all items in the MIB table.
{
SNMPPacket.Command = Gurux.SNMP.SnmpCommand.GetNext;
gxsnmp1.Send(SNMPPacket, SenderInfo);
}
else //Send button is disbled until command is finished.
{
SendBtn.Enabled = true;
}
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
''' <summary>
''' Show received data.
''' </summary>
Private Sub Gxsnmp1_OnReceived(ByVal sender As System.Object, ByVal SNMPPacket As Gurux.SNMP.GXSNMPPacket, ByVal SenderInfo As System.String) Handles Gxsnmp1.OnReceived
Try
If SNMPPacket.ErrorIndex <> 0 Then
MessageBox.Show(SNMPPacket.ErrorStatusAsString)
Exit Sub
End If
Dim it As Gurux.SNMP.GXSNMPDataItem
For Each it In SNMPPacket.DataItems
OIDList.Items.Add(it.OID + ": " + System.Convert.ToString(it.Data))
Next
Label4.Text = CStr(OIDList.Items.Count)
If bWalk Then
If Not SNMPPacket.IsWalkFinish Then 'If walk loop throw all items in the MIB table.
SNMPPacket.Command = Gurux.SNMP.SnmpCommand.GetNext
Gxsnmp1.Send(SNMPPacket, SenderInfo)
Else 'Send button is disbled until command is finished.
SendBtn.Enabled = True
End If
End If
Catch Ex As Exception
MessageBox.Show(Ex.Message)
End Try
End Sub
'New data from GXSNMP is received asynchronously
Private Sub GXSNMP1_OnReceived(ByVal sender As Object, ByRef Data As Variant, ByVal SenderInfo As String)
On Error GoTo GXErr
Dim Pack As GXSNMPPacket
Set Pack = Data
If Pack.ErrorIndex <> 0 Then
MsgBox Pack.ErrorStatusAsString
Exit Sub
End If
Dim pos As Integer
For pos = 0 To Pack.DataItems.Count - 1
'Don't show null OIDs
' If Pack.DataItems(pos).Type <> GX_SNMP_TYPE_NULL Then
OIDList.AddItem Pack.DataItems(pos).OID & ": " & CStr(Pack.DataItems(pos).Data)
Label4.Caption = OIDList.ListCount
'End If
Next
If bWalk Then
If Not Pack.IsWalkFinish Then 'If walk loop throw all items in the MIB table.
Pack.Command = GX_SNMP_COMMAND_GET_NEXT
GXSNMP1.Send Pack, SenderInfo
Else 'Send button is disbled until command is finished.
SendBtn.Enabled = True
End If
End If
Exit Sub
GXErr:
MsgBox Err.Description
End Sub
Assembly: Gurux.SNMP (Module: Gurux.SNMP) Version: 5.0.0.1