One of the easiest ways ive found out to do it is just to have a TStringList
as an communication input buffer. This will automatically parse the CrLf
separators in the incoming text.
i.e.
OnCSocketDataAvailable
...
buffer.text := buffer.text + incomingStr;
while (buffer.count > 1) or (copy (buffer.text, length (buffer.text) - 1, 2)
= #10#13) then
begin
processMessage (buffer.items [0]);
buffer.delete (0);
end;
I hope thats what you mean :-)
Or else use UDP, which ensures each bit of information you send is in its
own packet. This has its own problems though...
Wilfred.
-----Original Message-----
From: Steven Wild [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 10 August 1999 13:23
To: Multiple recipients of list delphi
Subject: RE: [DUG]: TCP/IP Socket messages
> The way to get around your problem is to put your messages into your own
> 'packets'. This means you start each message with a byte or two which
> determine the size of the message. When you receive a message you can
> read this, then wait for the right size to be imported into your buffer.
> Then you extract the right size of data, and process it. There may be
> some data in the buffer - which is the start of the next message.
>
> Hope this helps.
> --------------------------------------------------------------------------
I should have mentioned in my original email that we are using text
based messages from TClientSocket / TServerSocket i.e
CSocket.SendText('This is my text');
Rob
Steven Wild
Director
Wild Software Ltd
P O Box 33-216
Christchurch, NZ
Ph & Fax 64 3 377-0495
_______________________
Chreos Business Systems
_______________________
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz