NetworkStream.ReadByte Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
The NetworkStream is closed.
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
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈