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

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

NegotiateStream.EndRead メソッド

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

BeginRead の呼び出しで開始された、非同期の読み取り操作を終了します。

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

Public Overrides Function
 EndRead ( _
    asyncResult As IAsyncResult _
) As Integer
Dim instance As NegotiateStream
Dim asyncResult As IAsyncResult
Dim returnValue As Integer

returnValue = instance.EndRead(asyncResult)
public override int EndRead (
    IAsyncResult asyncResult
)
public:
virtual int EndRead (
    IAsyncResult^ asyncResult
) override
public int EndRead (
    IAsyncResult asyncResult
)
public override function EndRead (
    asyncResult : IAsyncResult
) : int

パラメータ

asyncResult

BeginRead の呼び出しによって返される IAsyncResult インスタンス。

戻り値
基になるストリームから読み取るバイト数を指定する Int32 値。

例外例外
例外の種類条件

ArgumentNullException

asyncResult が null 参照 (Visual Basic では Nothing) です。

ArgumentException

BeginRead への呼び出しで asyncResult が作成されませんでした。

InvalidOperationException

完了する保留中の読み取り操作がありません。

IOException

読み取り操作に失敗しました。

InvalidOperationException

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

解説解説

操作が完了していない場合、このメソッドは操作が完了するまでブロックします。

この操作を同期で実行するには、Read メソッドを使用します。

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

使用例使用例

非同期読み取り操作を終了するコード例を次に示します。操作を開始する例については、BeginRead のトピックを参照してください。

public static void EndReadCallback(IAsyncResult
 ar)
{
    // Get the saved data.
    ClientState cState = (ClientState) ar.AsyncState;
    TcpClient clientRequest = cState.Client;
    NegotiateStream authStream = (NegotiateStream) cState.AuthenticatedStream; 
    // Get the buffer that stores the message sent by the client.
    int bytes = -1;
    // Read the client message.
    try
    {
            bytes = authStream.EndRead(ar);
            cState.Message.Append(Encoding.UTF8.GetChars(cState.Buffer, 0, bytes));
            if (bytes != 0)
            {
                 authStream.BeginRead(cState.Buffer, 0, cState.Buffer.Length, 
                       new AsyncCallback(EndReadCallback), 
                       cState);
                       return;
         }
    }
    catch (Exception e)
    {
        // A real application should do something
        // useful here, such as logging the failure.
        Console.WriteLine("Client message exception:");
        Console.WriteLine(e);
        cState.Waiter.Set();
        return;
    }
    IIdentity id = authStream.RemoteIdentity;
    Console.WriteLine("{0} says {1}", id.Name, cState.Message.ToString());
    cState.Waiter.Set();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NegotiateStream クラス
NegotiateStream メンバ
System.Net.Security 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

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

   

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



NegotiateStream.EndRead メソッドのページの著作権

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

©2026 GRAS Group, Inc.RSS