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

SslStream.Read メソッド

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

このストリームからデータ読み取り指定した配列格納します

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

例外例外
例外種類条件

ArgumentNullException

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

ArgumentException

offset < 0.

または

offsetbuffer長さ超えてます。

または

offsetcount合計buffer長さ超えてます。

IOException

読み取り操作失敗しました内部例外存在する場合は、その例外チェックしてエラー原因確認してください

NotSupportedException

既に実行中の読み取り操作存在します

ObjectDisposedException

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

InvalidOperationException

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

解説解説

このメソッドは、count指定した最大バイトストリームから読み取りbuffer 内の offset で始まる位置格納します複数読み取り操作同時に実行することはできません。

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

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

使用例使用例

SslStream から読み取るコード例次に示します

static string ReadMessage(SslStream sslStream)
{
    // Read the  message sent by the server.
    // The end of the message is signaled using the
    // "<EOF>" marker.
    byte [] buffer = new byte[2048];
    StringBuilder messageData = new StringBuilder();
    int bytes = -1;
    do
    {
        bytes = sslStream.Read(buffer, 0, buffer.Length);
                
        // 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,bytes)];
        decoder.GetChars(buffer, 0, bytes, chars,0);
        messageData.Append (chars);
        // Check for EOF.
        if (messageData.ToString().IndexOf("<EOF>")
 != -1)
        {
            break;
        }
    } while (bytes != 0); 
    
    return messageData.ToString();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SslStream クラス
SslStream メンバ
System.Net.Security 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からSslStream.Read メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSslStream.Read メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSslStream.Read メソッド を検索

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

辞書ショートカット

すべての辞書の索引

「SslStream.Read メソッド」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS