|Subject:||Re: TIdBytes and SendBuffer|
|Posted by:||Remy Lebeau \(TeamB\) (firstname.lastname@example.org)|
|Date:||Sun, 8 Jul 2007|
"Thomas Bergerot" <email@example.com> wrote in message
> So if i want to use a pchar pointing to a buffer reserved with GetMem(),
> or if i want to use a record in memory, how can i do without creating a
> TIdBytes and copying the buffer in it before calling SendBuffer() ?
You can't. Indy 10 does not support operations on direct memory buffers.
That is part of its design in order to support .NET without maintaining a
separate codebase for it.
If you were using a TCP client instead of a UDP client, then I would say
that you could write a descendant of TIdMemoryStream to wrap your
pchar/record so Indy can send from it directly without allocating a
temporary TIdBytes for the data. But the UDP client does not support
sending streams, only buffers.
> Is there a way to cast my pchar or my record to inform SendBuffer()
> the size of the argument i pass ?
No. TIdBytes is a dynamic array. The memory layout would be different than
your pchar/record, so a simple cast will not work.
TIdBytes and SendBuffer posted by Thomas Bergerot on Sun, 08 Jul 2007