Advertisement
Guest User

Untitled

a guest
Oct 16th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.30 KB | None | 0 0
  1. public void ReadFully(byte[] b, int off, int len)
  2.     {
  3.         if(len < 0)
  4.         {
  5.             throw new IndexOutOfRangeException();
  6.         }
  7.  
  8.         int n = 0;
  9.         while(n < len)
  10.         {
  11.             int count = ClientInput.Read(b, off + n, len - n);
  12.             if(count < 0)
  13.             {
  14.                 throw new EndOfStreamException();
  15.             }
  16.             n += count;
  17.         }
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement