See Also

Agent Class  | Agent Members

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Languages PowerSNMP for .NET

Trace Event

Dart.PowerSNMP Namespace > Agent Class : Trace Event (Agent)

Occurs when an encoded datagram is sent or received.

[Visual Basic]
<CategoryAttribute("Trace")> <DescriptionAttribute("Raised when an encoded datagram is sent or received.")> Public Event Trace() As DatagramEventHandler
[C#]
[CategoryAttribute("Trace")] [DescriptionAttribute("Raised when an encoded datagram is sent or received.")] public event DatagramEventHandler Trace();
[C++]
[CategoryAttribute("Trace")] [DescriptionAttribute("Raised when an encoded datagram is sent or received.")] public: __event DatagramEventHandler* Trace();
[C++/CLI]
[CategoryAttribute("Trace")] [DescriptionAttribute("Raised when an encoded datagram is sent or received.")] public: event DatagramEventHandler^ Trace();

Event Data

The event handler receives an argument of type DatagramEventArgs containing data related to this event. The following DatagramEventArgs properties provide information specific to this event.

PropertyDescription
Buffer Gets the buffer holding the encoded SNMP message.
Count Gets the number of datagram bytes in the Buffer property.
Direction Gets the direction of the message.
RemoteEndPoint Gets the source or destination of the message.

Remarks

This event is useful for monitoring all datagram activity.

Example

The following example demonstrates how to keep a log file of incoming and outgoing packets.

[Visual Basic] 


Dim traceFile As System.IO.FileStream

Private Sub component_Trace(ByVal sender As Object, ByVal e As Dart.PowerSNMP.DatagramEventArgs) Handles component.Trace
    traceFile = New System.IO.FileStream(Application.StartupPath + "\trace.log", _
        System.IO.FileMode.Append, System.IO.FileAccess.Write)

    If (e.Direction = Direction.In) Then
        traceFile.Write(System.Text.Encoding.Default.GetBytes(vbCrLf + "In->"), 0, 6)
    Else
        traceFile.Write(System.Text.Encoding.Default.GetBytes(vbCrLf + "Out->"), 0, 7)
    End If

    traceFile.Write(e.Buffer, 0, e.Buffer.Length)

    traceFile.Close()
End Sub

[C#] 


System.IO.FileStream traceFile;

private void component_Trace(object sender, Dart.PowerSNMP.DatagramEventArgs e)
{
   traceFile =
new System.IO.FileStream(Application.StartupPath + "\\trace.log",
       System.IO.FileMode.Append, System.IO.FileAccess.Write);

   
if (e.Direction == Direction.In)
       traceFile.Write(System.Text.Encoding.Default.GetBytes(
"\r\nIn-&gt;"), 0, 6);
   
else
       
traceFile.Write(System.Text.Encoding.Default.GetBytes("\r\nOut-&gt;"), 0, 7);
   
   traceFile.Write(e.Buffer, 0, e.Buffer.Length);
           
   traceFile.Close();
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP, Windows Server 2003, Windows Vista

See Also

Agent Class  | Agent Members


Send comments on this topic.

Documentation version 1.2.0.0.

© 2008 Dart Communications.  All rights reserved.