2009-03-27 11 views
3

私はstream.DataAvailableを使用します。ここで、しかし、私はエラーを取得し、SSLStreamにNetworkStreamを使用してからC#コードを移行しています:SslStream.DataAvailableない有効な関数

Error 1 'System.Net.Security.SslStream' does not contain a definition for 'DataAvailable' and no extension method 'DataAvailable' accepting a first argument of type 'System.Net.Security.SslStream' could be found (are you missing a using directive or an assembly reference?)

今私の地元のMSDNのコピーがDataAvailableが含まれていません。しかし、SslStreamのメンバーとしてhttp://msdn.microsoft.com/en-us/library/dd170317.aspxには、メンバーDataAvailableがあると言われています。 ここに私のコードのコピーです。あなたは(後のコードでそれを行って、いくつかの解析があるでしょう)管理されているアレイにして、ストリームの私の出力を得るためのより良い方法を持っている場合

using System; 
using System.Collections; 
using System.Collections.Generic; 
using System.Net; 
using System.Net.Sockets; 
using System.Net.Security; 
using System.Security.Authentication; 
using System.Security.Cryptography.X509Certificates; 
using System.IO; 

namespace Node 
{ 

    public static class SSLCommunicator 
    { 
    static TcpClient client = null; 
    static SslStream stream = null; 
    static List<byte> networkStreamInput = new List<byte>(); 
    public static void connect(string server, Int32 port) 
    { 
     try 
     { 
      client = new TcpClient(server, port); 
      stream = new SslStream(client.GetStream(),false); 
    ... 
    ... 
    ... 
    public static List<DataBlock> getServerInput() 
    { 
     List<DataBlock> ret = new List<DataBlock>(); 
     try 
     { 
     //check to see if stream is readable. 
     if (stream.CanRead) 
     { 
     //Check to see if there is data available. 
     if (stream.DataAvailable) 
     { 
      byte[] readBuffer = new byte[1024]; 
      int numberOfBytesRead = 0; 
      //while data is available buffer the data. 
      do 
      { 
      numberOfBytesRead = stream.Read(readBuffer, 0, readBuffer.Length); 
      byte[] tmp = new byte[numberOfBytesRead]; 
      Array.Copy(readBuffer, tmp, numberOfBytesRead); 
      networkStreamInput.AddRange(tmp); 
      } while (stream.DataAvailable); 
    ... 

また、私は助けを大好きです。私はVisual Studio 2008を使用しています

--EDIT 私は組み込みSDKにリンクしていることを知りましたが、これは組み込みシステムではないので、データが通常の.net SDKで利用可能かどうかをどのように確認できますか?

答えて

2

ご覧のページは、.NET Micro Frameworkのページです。

this page for .Net 2.0this page for .Net 3.5によると、SSLStreamにはDataAvailableプロパティはありません。

編集:あなたはただRead()を呼び出して何か戻ってきてもらえませんか?私はこれがブロックされるとは思わない。

+0

いいえ:すべてが壊れています。参照:http://social.msdn.microsoft.com/Forums/en-US/f4c3d019-aecd-4fc6-9dea-680f04faa900/sslstreamread-returns-invalid-data – Ashe

関連する問題