Sending record with tcpclient/server

Giganews Newsgroups
Subject: Sending record with tcpclient/server
Posted by:  Simon A. (saberu…@tecnar-automation.com)
Date: Tue, 10 May 2005

Hi,

I want to send record over TCP/IP with TCPserver and TCPclient.

I know you can copy your structure to a dynamic record of byte and send it
with write like that :

var
Buf: TIdBytes;
begin
SetLength(Buf, sizeof(ARecord));
Move(ARecord, Buf[0], sizeof(ARecord));
IdTCPClient.IOHandler.Write(Buf);
end;

But the problem is, that I don't want to make a copy records everytime, that
makes a lot of data moving... I think that should be more straightforward
way to send record with a TCPserver and client! Do you have any suggestion
to be able to pass a record with minimum memory copy? I think this is the
kind of thing used very frequently, am I wrong?

Thank you

Simon

Replies