Επεξεργασία

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


NetworkStream.ReadByte Method

Definition

Reads a byte from the NetworkStream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

public:
 override int ReadByte();
public override int ReadByte ();
override this.ReadByte : unit -> int
Public Overrides Function ReadByte () As Integer

Returns

The unsigned byte cast to an Int32, or -1 if at the end of the stream.

Exceptions

The NetworkStream does not support reading.

An error occurred when accessing the socket.

-or-

There is a failure reading from the network.

Remarks

Note

Check to see if the NetworkStream is readable by calling the CanRead property. If you attempt to read from a NetworkStream that is not readable, you will get an InvalidOperationException.

Note

If you receive an IOException, check the InnerException property to determine if it was caused by a SocketException. If so, 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.

Applies to