NetworkStream.ReadByte Método
Definição
Lê um byte do NetworkStream e avança a posição no fluxo em um byte ou retorna -1 caso esteja no final do fluxo.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
Retornos
O byte sem sinal convertido em um Int32 ou -1 se o final do fluxo for atingido.The unsigned byte cast to an Int32, or -1 if at the end of the stream.
Exceções
O NetworkStream não oferece suporte à leitura.The NetworkStream does not support reading.
Ocorreu um erro ao acessar o soquete.An error occurred when accessing the socket.
- ou --or-
Ocorreu uma falha de leitura da rede.There is a failure reading from the network.
O NetworkStream está fechado.The NetworkStream is closed.
Comentários
Observação
Verifique se o NetworkStream é legível chamando a CanRead propriedade.Check to see if the NetworkStream is readable by calling the CanRead property. Se você tentar ler de um NetworkStream que não seja legível, receberá um InvalidOperationException .If you attempt to read from a NetworkStream that is not readable, you will get an InvalidOperationException.
Observação
Se você receber um IOException , verifique a InnerException propriedade para determinar se ela foi causada por um SocketException .If you receive an IOException, check the InnerException property to determine if it was caused by a SocketException. Nesse caso, use a ErrorCode propriedade para obter o código de erro específico e consulte a documentação do código de erro da API do Windows Sockets versão 2 para obter uma descrição detalhada do erro.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.