SslStream.BeginRead メソッド
アセンブリ: System (system.dll 内)

Public Overrides Function BeginRead ( _ 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.BeginRead(buffer, offset, count, asyncCallback, asyncState)
public override IAsyncResult BeginRead ( byte[] buffer, int offset, int count, AsyncCallback asyncCallback, Object asyncState )
public: virtual IAsyncResult^ BeginRead ( array<unsigned char>^ buffer, int offset, int count, AsyncCallback^ asyncCallback, Object^ asyncState ) override
public IAsyncResult BeginRead ( byte[] buffer, int offset, int count, AsyncCallback asyncCallback, Object asyncState )
public override function BeginRead ( buffer : byte[], offset : int, count : int, asyncCallback : AsyncCallback, asyncState : Object ) : IAsyncResult
戻り値
非同期操作のステータスを示す IAsyncResult オブジェクト。


暗号化や署名が有効になっている場合、読み取り操作では基になるストリームからのデータの読み取り、データの整合性チェック、データの復号化が行われます。非同期読み取り操作は、EndRead メソッドを呼び出して終了させる必要があります。通常、このメソッドは asyncCallback デリゲートによって呼び出されます。
このメソッドは、操作の実行中にブロックしません。操作が完了するまでブロックするには、Read メソッドを使用します。
非同期プログラミング モデルの使用法の詳細については、「同期メソッドの非同期呼び出し」を参照してください。
SslStream クラスは、複数の読み取り操作の同時実行をサポートしていません。
このメソッドは、正常に認証されるまで呼び出すことはできません。認証するには、AuthenticateAsClient、BeginAuthenticateAsClient、AuthenticateAsServer、BeginAuthenticateAsServer のいずれかのメソッドを呼び出します。

// readData and buffer holds the data read from the server. // They is used by the ReadCallback method. static StringBuilder readData = new StringBuilder(); static byte [] buffer = new byte[2048];
static void WriteCallback(IAsyncResult ar) { SslStream stream = (SslStream) ar.AsyncState; try { Console.WriteLine("Writing data to the server."); stream.EndWrite(ar); // Asynchronously read a message from the server. stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(ReadCallback), stream); } catch (Exception writeException) { e = writeException; complete = true; return; } }
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; }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からSslStream.BeginRead メソッドを検索する場合は、下記のリンクをクリックしてください。

- SslStream.BeginRead メソッドのページへのリンク