Export (0) Print
Expand All

NegotiateStream Constructor (Stream, Boolean)

Initializes a new instance of the NegotiateStream class using the specified Stream and stream closure behavior.

Namespace:  System.Net.Security
Assembly:  System (in System.dll)

public:
NegotiateStream(
	Stream^ innerStream, 
	bool leaveInnerStreamOpen
)

Parameters

innerStream
Type: System.IO::Stream

A Stream object used by the NegotiateStream for sending and receiving data.

leaveInnerStreamOpen
Type: System::Boolean

true to indicate that closing this NegotiateStream has no effect on innerstream; false to indicate that closing this NegotiateStream also closes innerStream. See the Remarks section for more information.

ExceptionCondition
ArgumentNullException

innerStream is nullptr.

- or -

innerStream is equal to Null.

When you specify true for the leaveStreamOpen parameter, closing the NegotiateStream has no effect on the innerStream stream; you must explicitly close innerStream when you no longer need it.

The following code example demonstrates calling this constructor. This code example is part of a larger example provided for the NegotiateStream class.

// Establish the remote endpoint for the socket. 
// For this example, use the local machine.
IPHostEntry^ ipHostInfo = Dns::GetHostEntry( Dns::GetHostName() );
IPAddress^ ipAddress = ipHostInfo->AddressList[ 0 ];

// Client and server use port 11000. 
IPEndPoint^ remoteEP = gcnew IPEndPoint( ipAddress,11000 );

// Create a TCP/IP socket.
client = gcnew TcpClient;

// Connect the socket to the remote endpoint.
client->Connect( remoteEP );
Console::WriteLine( L"Client connected to {0}.", remoteEP );

// Ensure the client does not close when there is  
// still data to be sent to the server.
client->LingerState = (gcnew LingerOption( true,0 ));

// Request authentication.
NetworkStream^ clientStream = client->GetStream();
NegotiateStream^ authStream = gcnew NegotiateStream( clientStream,false );

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft