1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Rep Power

    Delphi 6 Indy IdTCPServer - On unexpected disconnect wait for reconnect

    down votefavorite

    I have several programs made using Delphi 6 with Indy compenents and am trying to figure out a way to put a tcp connection on hold in case of an unforeseen disconnect. We connect via TCP to PLC's on our factory floor and for whatever reason (operator messing with things they shouldnt be, switches going down temporarily, faulty wire, or whatever the case may be)

    This causes our programs to lock up hard. As soon as a disconnect happens between plc and pc, the program will linger for a short amount of time and finally lock up. Is there a way to put the connection on hold when a disconnect between PLC and PC happens, and reestablish connection without locking the program up? Perhaps also is there a way to do this with IDTCPCLIENT as well?

    Any help would be greatly appreciated!

    If I need to be more descriptive please say so and I will try to be.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    South Africa
    Rep Power
    I am not sure how this is natively supported by the Indy components but, if not, I would suggest strating a separate thread (within the main process) that does the communication via TCP (also setting the timeout on your TCP connection). You thread can then run successfully in the background (or fail on timeout) without the main process being adversely affected.

    You can synchronize with your main thread to update labels / progress indicators so as not to have the screen just look 'blank'.

    You could also, after the timeout occurs, try an reconnect and continue doing so for a preset number of times (eg. 3 times), after which you fail, stop your thread and display to your user that communication failed.

    Perhaps a solution?

IMN logo majestic logo threadwatch logo seochat tools logo