Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : Re: no overloaded version of sendbuffer
| Subject: | Re: no overloaded version of sendbuffer |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Sun, 18 Nov 2007 13:02:12 |
"Pierre Lemerle" <plspam@free.fr> wrote in message
news:473ef83f@newsgroups.borland.com...
> Now with indy10 the commands are no longer
> valid : "no overloaded version of sendbuffer"
> is the error message.
You need to store your record data in a TIdBytes first. Indy 10 does not
allow to pass in arbitrary memory buffers anymore. The easiest way to get
such a TIdBytes is to call RawToBytes(), ie:
var
my_record: TObjectState;
my_buf: TIdBytes;
begin
my_buf := RawToBytes(my_record, SizeOf(my_record));
UDPClient.SendBuffer(my_buf);
end;
When receiving the data, it will be given to you as a TIdBytes as well. You
can use BytesToRaw() to copy it back into your record, ie:
procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
AData: TIdBytes; ABinding: TIdSocketHandle);
var
my_record: TObjectState;
begin
if Length(AData) >= SizeOf(my_record) then
begin
BytesToRaw(AData, my_record, SizeOf(my_record));
// use my_record as needed...
end;
end;
Gambit