PowerTCP Mail for .NET
Flush Method
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > SegmentedStream Class : Flush Method




Updates the underlying data source or repository with the current state of the buffer and then clears the buffer unless the internal Stream requires flushing..

Syntax

Visual Basic (Declaration) 
Public Overrides Sub Flush() 
Visual Basic (Usage)Copy Code
Dim instance As SegmentedStream
 
instance.Flush()
C# 
public override void Flush()
Managed Extensions for C++ 
public: void Flush(); override 
C++/CLI 
public:
void Flush(); override 

Example

The following example demonstrates writing data until a delimiter is reached.
Visual BasicCopy Code
' Create test data
Dim buffer As Byte() = System.Text.Encoding.Default.GetBytes("acbdefghijklmnopqrstuvwxyz" + vbCrLf)
Dim delimiter As Byte() = System.Text.Encoding.Default.GetBytes("ghi")

Dim offset As Integer = 0
Dim count As Integer = buffer.Length

' Connect to echo port
Tcp1.Connect("atropos", 7)

' Send data until the delimiter is reached.
Dim found As Boolean = Tcp1.Stream.Write(buffer, delimiter, offset, count)

' Flush the rest of the data
Tcp1.Stream.Flush()

' Recieve data.
Dim s As String = Tcp1.Stream.Read()

Debug.WriteLine(s)

'* Output
'* -----------------------
'* abcdef
C#Copy Code
// Create test data
byte[] buffer = System.Text.Encoding.Default.GetBytes("acbdefghijklmnopqrstuvwxyz\r\n");
byte[] delimiter = System.Text.Encoding.Default.GetBytes("ghi");
int offset = 0;
int count = buffer.Length;

// Connect to echo port
tcp1.Connect("atropos", 7);
			
// Send data until the delimiter is reached.
bool found = tcp1.Stream.Write(buffer, delimiter, ref offset, ref count);

// Flush the rest of the data
tcp1.Stream.Flush();

// Recieve data.
string s = tcp1.Stream.Read();

Debug.WriteLine(s);

/* Output
 * -----------------------
 * abcdef
 */

Remarks

All the read and write methods of SegmentedStream automatically maintain the buffer, so there is no need to invoke Flush when switching back and forth between reading and writing.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.