Export (0) Print
Expand All

NegotiateStream Constructor (Stream, Boolean)

Note: This constructor is new in the .NET Framework version 2.0.

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
)
public NegotiateStream (
	Stream innerStream, 
	boolean leaveInnerStreamOpen
)
public function NegotiateStream (
	innerStream : Stream, 
	leaveInnerStreamOpen : boolean
)

Parameters

innerStream

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

leaveInnerStreamOpen

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.

Exception typeCondition

ArgumentNullException

innerStream is a null reference (Nothing in Visual Basic).

- 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("localhost");
IPAddress ipAddress = ipHostInfo.AddressList[0];
// Client and server use port 11000. 
IPEndPoint remoteEP = new IPEndPoint(ipAddress, 11000);
// Create a TCP/IP socket.
client = new TcpClient();
// Connect the socket to the remote endpoint.
client.Connect(remoteEP);
Console.WriteLine("Client connected to {0}.", remoteEP.ToString());
// Ensure the client does not close when there is 
// still data to be sent to the server.
client.LingerState = (new LingerOption(true, 0));
// Request authentication.
NetworkStream clientStream = client.GetStream();
NegotiateStream authStream = new NegotiateStream(clientStream, false); 

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft