Socket.Available Property

Gets the amount of data that has been received from the network and is available to be read.

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

Syntax

public int Available { get; }

Property Value

The number of bytes of data received from the network and available to be read.

Remarks

If you are using a nonblocking socket, you can use the Available property to determine whether data is queued for reading, before calling the Receive method. The available data is the total amount of data that is queued for reading in the network buffer. If there is no data queued in the network buffer, the Available property returns 0 (zero).

If the remote host shuts down or closes the connection, Available can throw a SocketException exception. If you receive this type of exception, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows® Sockets 2.0 API error code documentation in the MSDN® Library for a detailed description of the error.

Version Information

Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, and 4.1.

See Also

Reference

Socket Class
Socket Members
System.Net.Sockets Namespace