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

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

SslStream.BeginWrite メソッド

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

指定したバッファからストリームByte書き込む非同期書き込み操作開始します

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

Public Overrides Function
 BeginWrite ( _
    buffer As Byte(), _
    offset As Integer, _
    count As Integer, _
    asyncCallback As AsyncCallback, _
    asyncState As Object _
) As IAsyncResult
Dim instance As SslStream
Dim buffer As Byte()
Dim offset As Integer
Dim count As Integer
Dim asyncCallback As AsyncCallback
Dim asyncState As Object
Dim returnValue As IAsyncResult

returnValue = instance.BeginWrite(buffer, offset, count, asyncCallback, asyncState)
public override IAsyncResult BeginWrite (
    byte[] buffer,
    int offset,
    int count,
    AsyncCallback asyncCallback,
    Object asyncState
)
public:
virtual IAsyncResult^ BeginWrite (
    array<unsigned char>^ buffer, 
    int offset, 
    int count, 
    AsyncCallback^ asyncCallback, 
    Object^ asyncState
) override
public IAsyncResult BeginWrite (
    byte[] buffer, 
    int offset, 
    int count, 
    AsyncCallback asyncCallback, 
    Object asyncState
)
public override function BeginWrite (
    buffer : byte[], 
    offset : int, 
    count : int, 
    asyncCallback : AsyncCallback, 
    asyncState : Object
) : IAsyncResult

パラメータ

buffer

ストリーム書き込むバイト提供する Byte 配列

offset

ストリーム書き込むバイト読み取り開始する位置を示す、buffer 内のインデックス番号が 0 から始まる位置

count

buffer から読み取るバイト数を指定する Int32 値。

asyncCallback

書き込み操作完了時に呼び出すメソッド参照する AsyncCallback デリゲート

asyncState

書き込み操作に関する情報格納するユーザー定義のオブジェクト。このオブジェクトは、操作完了時に asyncCallback デリゲート渡されます。

戻り値
非同期操作ステータスを示す IAsyncResult オブジェクト

例外例外
例外種類条件

ArgumentNullException

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

ArgumentException

offset < 0.

または

offsetbuffer長さ超えてます。

または

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

IOException

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

NotSupportedException

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

ObjectDisposedException

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

InvalidOperationException

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

使用例使用例

このメソッド呼び出すコード例次に示します

void ReadCallback(IAsyncResult ar)
{
    ClientState state = (ClientState) ar.AsyncState;
    SslStream stream = state.stream;
    // Read the  message sent by the client.
    // The end of the message is signaled using the
    // "<EOF>" marker.
    int byteCount = -1;
    try 
    {
        Console.WriteLine("Reading data from the client.");
        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(state.buffer,0,
 byteCount)];
        decoder.GetChars(state.buffer, 0, byteCount, chars,0);
        state.readData.Append (chars);
        // Check for EOF or an empty message.
        if (state.readData.ToString().IndexOf("<EOF>")
 == -1 && byteCount != 0)
        {
            // We are not finished reading.
            // Asynchronously read more message data from  the client.
            stream.BeginRead(state.buffer, 0, state.buffer.Length, 
                new AsyncCallback(ReadCallback),
                state);
        } 
        else
        {
            Console.WriteLine("Message from the client: {0}", state.readData.ToString());
        }
                      
        // Encode a test message into a byte array.
        // Signal the end of the message using "<EOF>".
        byte[] message = Encoding.UTF8.GetBytes("Hello from the server.<EOF>");
        // Asynchronously send the message to the client.
        stream.BeginWrite(message, 0, message.Length, 
            new AsyncCallback(WriteCallback),
            state);
    }
    catch (Exception readException)
    {
        Console.WriteLine("Read error: {0}", readException.Message);
        state.Close();
        return;
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SslStream クラス
SslStream メンバ
System.Net.Security 名前空間



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS