Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get size of TIdMessage without first saving to TStream
#2
Indy has a TIdCalculateSizeStream class in the IdGlobal unit. It acts similar to TMemoryStream but without using an actual memory buffer. It is intended to be used for exactly this kind of scenario - counting the number of bytes "written" to it. You can use it in the exact same way as before - save the TIdMessage to it, and then read its Size property.

Just note that TIdMessage generates its stream data dynamically, so there is no guarantee that the byte count will be exactly the same number each time you call its SaveTo...() methods, even if you don't change any of its properties in between calls. Particularly in regards to timestamps, message part boundaries, etc. So calculating the size of a TIdMessage is more of an estimate than an absolute.

Reply


Messages In This Thread
RE: Get size of TIdMessage without first saving to TStream - by rlebeau - 11-13-2018, 07:13 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)