Export (0) Print
Expand All

NetworkStream.Writeable Property

Gets a value that indicates whether the NetworkStream is writable.

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

protected bool Writeable { get; set; }

Property Value

Type: System.Boolean
true if data can be written to the stream; otherwise, false. The default value is true.

You must derive from the NetworkStream class to use the Writeable property. If Writeable is true, NetworkStream allows calls to the Write method. You can also determine whether a NetworkStream is writable by checking the publicly accessible CanWrite property.

The Writeable property is set when the NetworkStream is initialized.

In the following code example, the CanCommunicate property checks the Writeable property to determine if the NetworkStream is writable.

using System;
using System.Net;
using System.Net.Sockets;


public class MyNetworkStream_Sub_Class : NetworkStream
{

    public MyNetworkStream_Sub_Class(Socket socket, bool ownsSocket) :
        base(socket, ownsSocket)
    {
    }
    // You can use the Socket method to examine the underlying Socket. 
    public bool IsConnected
    {
        get
        {
            return this.Socket.Connected;
        } 
    }

    public bool CanCommunicate
    {
        get
        {
            if (!this.Readable | !this.Writeable)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft