public int ReadFrom(IInputStream stream) { int received = stream.Receive(buffer, endIndex, buffer.Length - endIndex); endIndex += received; return received; }