NegotiateStream 생성자

정의

NegotiateStream 클래스의 새 인스턴스를 초기화합니다.

오버로드

Name Description
NegotiateStream(Stream)

지정된 을 사용하여 클래스의 NegotiateStream 새 인스턴스를 Stream초기화합니다.

NegotiateStream(Stream, Boolean)

지정된 및 스트림 닫기 동작을 NegotiateStream 사용하여 클래스의 새 인스턴스를 Stream 초기화합니다.

설명

사용자가 제공하는 스트림을 NegotiateStream 닫지 않도록 하려면 생성자를 사용합니다 NegotiateStream(Stream, Boolean) .

NegotiateStream(Stream)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

지정된 을 사용하여 클래스의 NegotiateStream 새 인스턴스를 Stream초기화합니다.

public:
 NegotiateStream(System::IO::Stream ^ innerStream);
public NegotiateStream(System.IO.Stream innerStream);
new System.Net.Security.NegotiateStream : System.IO.Stream -> System.Net.Security.NegotiateStream
Public Sub New (innerStream As Stream)

매개 변수

innerStream
Stream

Stream 데이터를 보내고 받는 데 사용되는 NegotiateStream 개체입니다.

예제

다음 코드 예제에서는이 생성자를 호출 하는 방법을 보여 줍니다.

 // 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 = new IPEndPoint(ipAddress,11000);
 // Create a TCP/IP socket.
TcpClient 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);
 // Request authentication for the client only (no mutual authentication).
 // Authenicate using the client's default credetials.
 // Permit the server to impersonate the client to access resources on the server only.
 // Request that data be transmitted using encryption and data signing.
 authStream.AuthenticateAsClient(
      (NetworkCredential) CredentialCache.DefaultCredentials,
      "",
      ProtectionLevel.EncryptAndSign,
      TokenImpersonationLevel.Impersonation);

적용 대상

NegotiateStream(Stream, Boolean)

Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs
Source:
NegotiateStream.cs

지정된 및 스트림 닫기 동작을 NegotiateStream 사용하여 클래스의 새 인스턴스를 Stream 초기화합니다.

public:
 NegotiateStream(System::IO::Stream ^ innerStream, bool leaveInnerStreamOpen);
public NegotiateStream(System.IO.Stream innerStream, bool leaveInnerStreamOpen);
new System.Net.Security.NegotiateStream : System.IO.Stream * bool -> System.Net.Security.NegotiateStream
Public Sub New (innerStream As Stream, leaveInnerStreamOpen As Boolean)

매개 변수

innerStream
Stream

Stream 데이터를 보내고 받는 데 사용되는 NegotiateStream 개체입니다.

leaveInnerStreamOpen
Boolean

trueNegotiateStream 는 것이 영향을 innerStream주지 않음을 나타내려면 ; falseNegotiateStream 는 것도 닫힙니다.innerStream

예외

innerStreamnull입니다.

-또는-

innerStream가 같음 Null

예제

다음 예제에서는이 생성자를 호출 하는 방법을 보여 줍니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 NegotiateStream 일부입니다.

// 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);
' Establish the remote endpoint for the socket.
' For this example, use the local machine.
Dim ipHostInfo = Dns.GetHostEntry("localhost")
Dim ipAddress = ipHostInfo.AddressList(0)

' Client and server use port 11000. 
Dim remoteEP As 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.
Dim clientStream = client.GetStream()
Dim authStream As New NegotiateStream(clientStream, False)

설명

매개 변수를 지정할 true 때 닫는 leaveStreamOpen 것은 스트림에 NegotiateStream 영향을 주지 않습니다. 더 이상 필요하지 않을 때 명시적으로 닫 innerStream 아야 innerStream 합니다.

적용 대상