See Also

SegmentedStream Class  | SegmentedStream 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

Flush Method

Dart.PowerTCP.SslSockets Namespace > SegmentedStream Class : Flush Method (SegmentedStream)

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..

[Visual Basic]
Overrides Public Sub Flush()
[C#]
public override void Flush();
[C++]
public: void Flush(); override
[C++/CLI]
public: void Flush(); override

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.

Example

The following example demonstrates writing data until a delimiter is reached.

[Visual Basic] 

' 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#] 


// 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
*/
                

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

SegmentedStream Class  | SegmentedStream Members


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.