See Also

Tcp Class  | Tcp Members

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Languages PowerTCP SSL Sockets for .NET

Trace Event

Dart.PowerTCP.SslSockets Namespace > Tcp Class : Trace Event (Tcp)

Raised when data has been sent/received.

[Visual Basic]
<DescriptionAttribute("Provides advanced runtime debugging")> <CategoryAttribute("Connection")> Public Event Trace() As SegmentEventHandler
[C#]
[DescriptionAttribute("Provides advanced runtime debugging")] [CategoryAttribute("Connection")] public event SegmentEventHandler Trace();
[C++]
[DescriptionAttribute("Provides advanced runtime debugging")] [CategoryAttribute("Connection")] public: __event SegmentEventHandler* Trace();
[C++/CLI]
[DescriptionAttribute("Provides advanced runtime debugging")] [CategoryAttribute("Connection")] public: event SegmentEventHandler^ Trace();

Event Data

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

PropertyDescription
Exception Gets any exception which occurred during the asynchronous operation.
Segment The Segment object referencing the data that was sent or received.
State Gets the object that was included as part of the associated method call.

Remarks

This event is raised when commands or data has been sent/received. If you are using a component which uses TCP as the transport protocol a SegmentEventArgs object is passed into the event containing any commands or data sent or received. If you are using a component which uses UDP as the transport protocol a DatagramEventArgs object is passed into the event containing any commands or data sent or received.

The Object.RawTrace event always reports actual data sent/received over the socket. The Count of each segment reflects the number of bytes actually written and received. The Object.Trace event reports data sent/received at a higher level. For example, for the Telnet component, Object.Trace reports data sent/received, but does not report IAC option sequences that are processed by TelnetStream, whereas Object.RawTrace allows you to trace the actual data sent/received, including Telnet option commands.

If you are using the PowerTCP component as a reference, you must create a method to handle the event yourself. For more information on using events using PowerTCP.NET within the Visual Studio.NET environment, see Using Events In PowerTCP.

Example

The following example demonstrates using the Tcp component's Trace event to create a log of all data sent and received.

[Visual Basic] 

Private Sub Tcp1_Trace(ByVal sender As Object, ByVal e As SegmentEventArgs) Handles Tcp1.Trace
   ' Get the data into a byte array
   Dim buffer As Byte() = System.Text.Encoding.Default.GetBytes(e.Segment.ToString())

   ' Create a FileStream
   Dim f As New FileStream("C:\test\socketlog.log", FileMode.Append)

   ' Write the data to the file.
   f.Write(buffer, 0, buffer.Length)
   f.Close()
End Sub

[C#] 


private void tcp1_Trace(object sender, SegmentEventArgs e)
{
  
// Get the data into a byte array
  
byte[] buffer = System.Text.Encoding.Default.GetBytes(e.Segment.ToString());
           
  
// Create a FileStream
  
FileStream f = new FileStream("C:\\test\\socketlog.txt", FileMode.Append);

  
// Write the data to the file.
  
f.Write(buffer, 0, buffer.Length);
  f.Close();
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Tcp Class  | Tcp Members


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.