Send array of string using tcp

Posted by user2798455 on Stack Overflow See other posts from Stack Overflow or by user2798455
Published on 2013-10-20T05:14:55Z Indexed on 2013/10/20 15:54 UTC
Read the original article Hit count: 215

Filed under:
|

I'm not sure if this is possible but here it goes. Usually I send strings like this...

Connection.IOHandler.WriteLn('alpha');
Connection.IOHandler.WriteLn('bravo');
Connection.IOHandler.WriteLn('charley');
//and so on..

But what if I want to send it in just one go, just send it all at once. Maybe I could put it on an array of strings then send the array.

someStr : array[1..3] of string = ('alpha','bravo','charley');//this could be more

...

StrListMem := TMemoryStream.Create;
try

   StrListMem.WriteBuffer(someStr[0], Length(someStr));
   StrListMem.Position:=0;

   Connection.IOHandler.Write(StrListMem, 0, True);

finally
   StrListMem.Free;
end;

I just have no idea how to this right, maybe somebody can give an example? and how the receiver(client) will read it.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-xe