Re: TIdBytes and SendBuffer

Giganews Newsgroups
Subject: Re: TIdBytes and SendBuffer
Posted by:  Remy Lebeau \(TeamB\) (no.spam@no.spam.com)
Date: Sun, 8 Jul 2007

"Thomas Bergerot" <nospam@nospam.fr> wrote in message
news:CC71329AF92CE340nospam@nospam.fr...

> 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.

Gambit

Replies

None

In response to

TIdBytes and SendBuffer posted by Thomas Bergerot on Sun, 08 Jul 2007