Writeable Property

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)

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 Connected
    {
        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_Connected()
    {
        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 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2016 Microsoft