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 */
protected boolean get_Writeable ()

/** @property */
protected void set_Writeable (boolean value)

protected function get Writeable () : boolean

protected function set Writeable (value : boolean)

Not applicable.

Property Value

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;
            }
        }
    }

import System.*;  
import System.Net.*;  
import System.Net.Sockets.*;  

public class MyNetworkStreamSubClass extends NetworkStream
{
    public MyNetworkStreamSubClass(Socket socket, boolean ownsSocket)
    {
      super(socket, ownsSocket);
    } //MyNetworkStreamSubClass

    // You can use the Socket method to examine the underlying Socket.
    /** @property 
     */
    public boolean get_IsConnected()
    {
        return this.get_Socket().get_Connected();
    } //get_Connected

    /** @property 
     */
    public boolean get_CanCommunicate()
    {
        if (!(this.get_Readable()) | !(this.get_Writeable())) {
            return false;
        }
        else {
            return true;
        }
    } //get_CanCommunicate

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: