コード例 #1
0
 /// <exception cref="System.IO.IOException"></exception>
 public override void Write(byte[] b, int off, int len)
 {
     while (0 < len)
     {
         int capacity = buffer.Length - cnt;
         if (cnt == HDR_SIZE && capacity < len)
         {
             // Our block to write is bigger than the packet size,
             // stream it out as-is to avoid unnecessary copies.
             PacketLineOut.FormatLength(buffer, buffer.Length);
             @out.Write(buffer, 0, HDR_SIZE);
             @out.Write(b, off, capacity);
             off += capacity;
             len -= capacity;
         }
         else
         {
             if (capacity == 0)
             {
                 WriteBuffer();
             }
             int n = Math.Min(len, capacity);
             System.Array.Copy(b, off, buffer, cnt, n);
             cnt += n;
             off += n;
             len -= n;
         }
     }
 }
コード例 #2
0
 /// <exception cref="System.IO.IOException"></exception>
 private void WriteBuffer()
 {
     PacketLineOut.FormatLength(buffer, cnt);
     @out.Write(buffer, 0, cnt);
     cnt = HDR_SIZE;
 }