Επεξεργασία

Κοινή χρήση μέσω


NetworkStream.DataAvailable Property

Definition

Gets a value that indicates whether data is available on the NetworkStream to be immediately read.

public:
 virtual property bool DataAvailable { bool get(); };
public virtual bool DataAvailable { get; }
member this.DataAvailable : bool
Public Overridable ReadOnly Property DataAvailable As Boolean

Property Value

true if data is available on the stream to be read; otherwise, false.

Exceptions

The underlying Socket is closed.

Use the ErrorCode property to obtain the specific error code and refer to the Windows Sockets version 2 API error code documentation for a detailed description of the error.

Remarks

Use the DataAvailable property to determine if data is queued to be immediately read. If DataAvailable is true, a call to Read returns immediately. If the remote host shuts down or closes the connection, DataAvailable may throw a SocketException.

Note

Do not use DataAvailable to determine whether the transmission has ended. Even if there's no data available to be immediately read, the underlying socket may receive more data later.

Applies to

See also