private void ReadMessage(Stream stream, byte[] messageByte, int offset, int size) { if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { while (offset < size) { int byteLetti = stream.Read(messageByte, offset, size - offset); if (byteLetti == 0) { SocketClosedException sce = new SocketClosedException(); throw new IOException("No data avaible to read", sce); } offset += byteLetti; } } else { throw new NetworkException(); } }
private void ReadMessage(Stream stream, byte[] messageByte, int offset, int size) { if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) { while (offset < size) { int byteLetti = stream.Read(messageByte, offset, size - offset); if (byteLetti == 0) { SocketClosedException sce = new SocketClosedException(); throw new IOException("No data avaible to read", sce); } offset += byteLetti; } } else { throw new NetworkException(); } }