I am migrating C# code from using a NetworkStream to SSLStream, however where I use stream.DataAvailable I get the error:
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?)
now my local MSDN copy does not include DataAvailable as a member of SslStream however http://msdn.microsoft.com/en-us/library/dd170317.aspx says it does have the member DataAvailable. 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);
...
Also if you have a better way to get my output of the stream in to a managed array (there will be some parsing done on it later in the code) I would love the help. I am using Visual Studio 2008
--EDIT I just realized I linked to the embedded SDK, this is not a embedded system, so how do I see if data is available in the normal .net SDK?