SslStream.DataAvailable is not a valid function

I port C # code using NetworkStream to SSLStream, however, when I use stream.DataAvailable, I get an error:

Error 1 'System.Net.Security.SslStream' does not contain a definition for "DataAvailable" and there is no extension for the "DataAvailable" method that takes the first argument of the type "System.Net.Security.SslStream" maybe (do you miss a directive or an assembly reference? )

now my local copy of MSDN does not include DataAvailable as an SslStream member, however http://msdn.microsoft.com/en-us/library/dd170317.aspx says it has a DataAvailable member. here is a copy of my code.

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, , , SDK?.net?

+3
1

, , .NET Micro Framework.

.Net 2.0 .Net 3.5, SSLStream DataAvailable.

: Read() , -? , .

+2

Source: https://habr.com/ru/post/1705480/


All Articles