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

SslStream.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 SslStream
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

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

ArgumentException

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

InvalidOperationException

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

IOException

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

InvalidOperationException

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

解説解説

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

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

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

使用例使用例

非同期読み取り操作終了するコード例次に示します

static void ReadCallback(IAsyncResult ar)
{
    // Read the  message sent by the server.
    // The end of the message is signaled using the
    // "<EOF>" marker.
    SslStream stream = (SslStream) ar.AsyncState;
    int byteCount = -1;
    try 
    {
        Console.WriteLine("Reading data from the server.");
        byteCount = stream.EndRead(ar);
        // Use Decoder class to convert from bytes to UTF8
        // in case a character spans two buffers.
        Decoder decoder = Encoding.UTF8.GetDecoder();
        char[] chars = new char[decoder.GetCharCount(buffer,0,
 byteCount)];
        decoder.GetChars(buffer, 0, byteCount, chars,0);
        readData.Append (chars);
        // Check for EOF or an empty message.
        if (readData.ToString().IndexOf("<EOF>")
 == -1 && byteCount != 0)
        {
            // We are not finished reading.
            // Asynchronously read more message data from  the server.
            stream.BeginRead(buffer, 0, buffer.Length, 
                new AsyncCallback(ReadCallback),
                stream);
        } 
        else
        {
            Console.WriteLine("Message from the server: {0}", readData.ToString());
        }
    }
    catch (Exception readException)
    {
        e = readException;
        complete = true;
        return;
    }
    complete = true;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SslStream クラス
SslStream メンバ
System.Net.Security 名前空間



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS