Delphi and TIdTCPServer.OnExecute: how to combine data correctly

A very simple question to which I can not find a definitive answer.

I have a classic TCP Indy server. I am sending data in chunks. Each data packet is sent in 1 or more pieces. When it arrives, OnExecute is launched one or more times for each packet. More than one client can send data at any given time. How to find out which client / package I receive data in OnExecute? I probably know his trivial question, but I want a final answer.

+4
source share
1 answer

If you can create a protocol, this can be done as follows:

  • the client starts with an initial command that includes the total size and block size
  • OnExecute server creates a temporary stream of output files and stores file information in context
  • client sends pieces
  • OnExecute server reads fragments (using Indy TCP server read blocking with known block length) and adds them to the output stream

The Indy TCP context class can be extended to add user information for a client connection.

+3
source

Source: https://habr.com/ru/post/1403630/


All Articles