NegotiateStream Constructeurs
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Initialise une nouvelle instance de la classe NegotiateStream.
Surcharges
| Nom | Description |
|---|---|
| NegotiateStream(Stream) |
Initialise une nouvelle instance de la NegotiateStream classe à l’aide du .Stream |
| NegotiateStream(Stream, Boolean) |
Initialise une nouvelle instance de la NegotiateStream classe à l’aide du comportement de fermeture de flux et spécifié Stream . |
Remarques
Pour empêcher la NegotiateStream fermeture du flux que vous fournissez, utilisez le NegotiateStream(Stream, Boolean) constructeur.
NegotiateStream(Stream)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
Initialise une nouvelle instance de la NegotiateStream classe à l’aide du .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)
Paramètres
- innerStream
- Stream
Objet Stream utilisé par l’envoi et la NegotiateStream réception de données.
Exemples
L’exemple de code suivant illustre l’appel de ce constructeur.
// 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);
S’applique à
NegotiateStream(Stream, Boolean)
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
- Source:
- NegotiateStream.cs
Initialise une nouvelle instance de la NegotiateStream classe à l’aide du comportement de fermeture de flux et spécifié 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)
Paramètres
- innerStream
- Stream
Objet Stream utilisé par l’envoi et la NegotiateStream réception de données.
- leaveInnerStreamOpen
- Boolean
true pour indiquer que la fermeture NegotiateStream n’a aucun effet sur innerStream; false pour indiquer que la fermeture de ce NegotiateStream dernier ferme innerStreamégalement .
Exceptions
Exemples
L’exemple suivant illustre l’appel de ce constructeur. Cet exemple de code fait partie d’un exemple plus grand fourni pour la NegotiateStream classe.
// 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)
Remarques
Lorsque vous spécifiez true pour le paramètre, la leaveStreamOpen fermeture du NegotiateStreaminnerStream flux n’a aucun effet ; vous devez fermer innerStream explicitement lorsque vous n’en avez plus besoin.