Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with Indy TCPClient or IOHandler
#3
(06-28-2018, 05:51 PM)rlebeau Wrote: I assume you mean Indy 10 in XE2. 

Thanks for the quick reply, yes i mean XE2. 

(06-28-2018, 08:32 AM)rlebeau Wrote: That is generally not a good idea.  You really should be using a worker thread for that, to avoid blocking the UI.

The Indy TCPClient component is not directly use in UI and doesn't have direct interaction with UI, The Main Thread that I am referring to is implemented in dll. Then we have a standalone UI application that loads the dll.    

(06-28-2018, 08:32 AM)rlebeau Wrote: Calling ReadBytes() in that way returns whatever bytes are currently in the socket *at that moment*.  Is that what you really want?  That runs the risk of receiving partiual data, is your code prepared to handle that possibility?  Doesn't the communications have structure to it?  You are sending a terminator after your outgoing data, does the inbound data have a similar terminator on each message?  If so, then why not use IOHandler.ReadLn() or IOHandler.WaitFor() with that terminator passed in as a parameter?

The code can handle partial data. Yes it has a communication structure with terminator for outbound and inbound data. We didn't have any problem reading the data.

(06-28-2018, 08:32 AM)rlebeau Wrote: All the more reason NOT to do non-UI work in the main UI thread.  It doesn't belong there.

The implementation of TCPClient that send to server is not in UI Main Thread.

(06-28-2018, 08:32 AM)rlebeau Wrote: Without seeing your actual code, that kind of behavior implies to me that the UI thread is blocked waiting to receive a reply to something it thinks was sent out but really wasn't, so when the worker thread sends it out, it unblocks whatever the UI thread is waiting for.

I might consider writing a worker Thread inside the dll. Are there ways to know when the thread is blocked and probably the best way to unblock it?

(06-28-2018, 08:32 AM)rlebeau Wrote: I can't really answer that since you did not show any of your code.

My Boss wouldn't allow me to post the code here.
Reply


Messages In This Thread
RE: Problem with Indy TCPClient or IOHandler - by Ayodeji - 06-29-2018, 02:41 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)