Search code examples
delphitcpnetwork-programmingararat-synapse

Sync TCP Client in multi-client application without lags


I have application, whitch connents to N devices trought the network. The problem is: TCP Client class isn't async, I'm send the command to device, I want get answer now. So, 2 or more active clients makes my app frozen.

Any ideas how to do some, that's will not freeze my application if many devices is enabled at one time?

TCP Client class uses Synapse classes package.

Thanks!


Solution

  • To avoid application hang, use a separate thread for every TCP client connection.

    The thread then will run independently, connect to the device, and do the communication.

    Note that the thread must not access objects/data in the main application thread without proper synchronization.