NegotiateStream.Write メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > NegotiateStream.Write メソッドの意味・解説 

NegotiateStream.Write メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

指定したバッファオフセット使用して、基になるストリーム指定した Byte 数を書き込みます

名前空間: System.Net.Security
アセンブリ: System (system.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

buffernull 参照 (Visual Basic では Nothing) です。

ArgumentException

offset is less than 0.

または

offsetbuffer長さ超えてます。

または

offsetcount加算した値が、buffer長さ超えてます。

IOException

書き込み操作失敗しました

または

暗号化使用されていますが、データ暗号化できませんでした

NotSupportedException

既に実行中の書き込み操作存在します

ObjectDisposedException

このオブジェクト閉じられています。

InvalidOperationException

認証が行われていません。

解説解説

暗号化署名、または暗号化署名有効になっている場合、このメソッドが、バッファからのデータ読み込み読み込んだデータ暗号化署名、または暗号化署名、および基になるストリーム使用したデータ送信行いますデータ暗号化署名などのセキュリティ サービス使用されていない場合、このメソッドは基になるストリームで M:Write呼び出します。

このメソッドは、書き込み操作実行中にブロックします操作完了するまでブロックしないようにするには、Write メソッド使用します

このメソッドは、正常に認証されるまで呼び出すことはできません。認証するには、AuthenticateAsClient、BeginAuthenticateAsClient、AuthenticateAsServer、または BeginAuthenticateAsServer のいずれかメソッド呼び出します。

NegotiateStream クラスは、複数書き込み操作同時実行サポートしていません。同じストリームで既に書き込み操作実行中であるときに、別の書き込み操作開始しようとすると、NotSupportedException 例外スローさます。

使用例使用例

NegotiateStream書き込みを行うコード例次に示します

    public static void Main(String[]
 args)  
    {
        // 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);
        DisplayAuthenticationProperties(authStream);
        DisplayStreamProperties(authStream);
        if (authStream.CanWrite)
        {
             // Encode the test data into a byte array.
            byte[] message = System.Text.Encoding.UTF8.GetBytes("Hello from
 the client.");
            authStream.Write(message, 0, message.Length);
      authStream.Flush();
            Console.WriteLine("Sent {0} bytes.", message.Length);
     }
     // Close the client connection.
        authStream.Close();
        Console.WriteLine("Client closed.");
        
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NegotiateStream クラス
NegotiateStream メンバ
System.Net.Security 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

NegotiateStream.Write メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



NegotiateStream.Write メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS