NetworkStream::Readable Property

 

Gets or sets a value that indicates whether the NetworkStream can be read.

Namespace:   System.Net.Sockets
Assembly:  System (in System.dll)

protected:
property bool Readable {
	bool get();
	void set(bool value);
}

Property Value

Type: System::Boolean

true to indicate that the NetworkStream can be read; otherwise, false. The default value is true.

You must derive from the NetworkStream class to use the Readable property. If Readable is true, NetworkStream allows calls to the Read method. You can also determine whether a NetworkStream is readable by checking the publicly accessible CanRead property.

The Readable property is set when the NetworkStream is initialized.

In the following code example, the CanCommunicate property checks the Readable property to determine if the NetworkStream is readable.

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Net::Sockets;

ref class MyNetworkStream_Sub_Class: public NetworkStream
{
public:
   MyNetworkStream_Sub_Class( System::Net::Sockets::Socket^ socket, bool ownsSocket )
      : NetworkStream( socket, ownsSocket )
   {
   }

   property bool IsConnected 
   {
      // You can use the Socket method to examine the underlying Socket.
      bool get()
      {
         return this->Socket->Connected;
      }
   }

   property bool CanCommunicate 
   {
      bool get()
      {
         if ( !this->Readable | !this->Writeable )
         {
            return false;
         }
         else
         {
            return true;
         }
      }
   }

.NET Framework
Available since 1.1
Return to top
Show: