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
{
if (stream.CanRead)
{
if (stream.DataAvailable)
{
byte[] readBuffer = new byte[1024];
int numberOfBytesRead = 0;
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?