PowerTCP Mail for .NET
SegmentedStream Constructor(Stream,Encoding)
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > SegmentedStream Class > SegmentedStream Constructor : SegmentedStream Constructor(Stream,Encoding)




stream
The source stream to Read/Write.
encoding
The encoding type to use when working with strings.
Initializes a new instance of the SegmentedStream class for the specified stream object.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal stream As Stream, _
   ByVal encoding As Encoding _
)
Visual Basic (Usage)Copy Code
Dim stream As Stream
Dim encoding As Encoding
 
Dim instance As New SegmentedStream(stream, encoding)
C# 
public SegmentedStream( 
   Stream stream,
   Encoding encoding
)
Managed Extensions for C++ 
public: SegmentedStream( 
   Stream* stream,
   Encoding* encoding
)
C++/CLI 
public:
SegmentedStream( 
   Stream^ stream,
   Encoding^ encoding
)

Parameters

stream
The source stream to Read/Write.
encoding
The encoding type to use when working with strings.

Example

The following example demonstrates initializing a new instance of a SegmentedStream object to a TcpStream.
Visual BasicCopy Code
' Connect to a server
Tcp1.Connect("atropos", 7)

' Initialize a SegmentedStream to the NetworkStream
Dim sstream As New SegmentedStream(new TcpStream(Tcp1))

' Send data
sstream.Write("hello")

' Receive data
Dim s As String = sstream.Read()
C#Copy Code
// Connect to a server
tcp1.Connect("atropos", 7);

// Initialize a SegmentedStream to the NetworkStream
SegmentedStream sstream = new SegmentedStream(new TcpStream(tcp1));

// Send data
sstream.Write("hello");

// Receive data
string s = sstream.Read();

Remarks

Although any type of stream can be used to initialize a SegmentedStream (a FileStream or a MemoryStream, for example) the intended use is to initialize a SegmentedStream with some form of network stream (such as a TcpStream). You will not usually need to create a SegmentedStream object, as the SegmentedStream object currently accessing the TCP stream is made accessible (either as a property of the component, or as an object accessible in an event or returned from a method). For example, if you wish to send/receive data to/from a server using a stream interface, simply use Tcp.Connect to connect to the server and call Tcp.Stream.Write or Tcp.Stream.Read to send/receive data.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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