One way that I have used is to precede the string with an fixed width field
that stores the length of the string. Example:
var
string11, string2, concatstring: string;
begin
string1 := 'Test string1';
string2 := 'Test string2';
ConcatString := IntToHex (Length(string1), 8) + string1 + IntToHex
(Length(string2), 8) + string2;
ConcatString now holds:
'00000008Test string100000008Test string2'
Then unpacking is a simple matter of reading the first 8 characters,
converting that to an integer, and use that to read the correct number of
bytes into the sting:
var
string11, string2, concatstring: string;
sLength: string;
iLength: Integer;
begin
sLength := Copy (ConcatString, 1, 8);
iLength := StrToInt ('$' + sLength);
string1 := Copy (ConcatString, 9, iLength);
ConcatString := Copy (ConcatString, 9 + iLength);
sLength := Copy (ConcatString, 1, 8);
iLength := StrToInt ('$' + sLength);
string2 := Copy (ConcatString, 9, iLength);
Hope this helps,
Dennis.
> -----Original Message-----
> What is the best way to communicate a bunch of strings through udp?
>
> I thought of concatenating them altogether with some symbol
> between (say &),
> but how would I go about unpacking it?
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz