Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1329
  • Last Modified:

idtcpclient problem

I've got some code like the following on client side. The TCPServer is
handling everything with command handlers.
In the following code, the first response to command 'RINI' is working
all fine. However, on the following sendcmd(RDBNAMES) line, the client
is freezing. In the meantime, the idtcpclient.connect method is in
initialization and i want the client application to be connected to
the server all times until application.terminate.

What am i doing wrong in this freezing line?

   on E : Exception do ShowMessage(E.Message);
   rInit_Sysaudit       := remoteinifile.ReadBool('INIT', 'SYSAUDIT',
   rLogin_Optionsfolder := remoteinifile.ReadString('LOGIN',
   rDirectories_DefaultDir := remoteinifile.ReadString('DIRECTORIES',
-->Freezing in the following line!


Thanks in advance,
1 Solution
Hello febalci.
  In response to your topic i'm wirting the next:
  I happend to crush onto the same problem once, and I fixed it in a realy simple way:
  Onto the CommandHandler's OnCommand event, First of all I wrote the next line, Asender.SendReply; , I don't quite know way, but it seems even if the server object sends the response automatically the client objects doesn't detect it like that, and keeps waiting for the response, so if you wanna send another command, it will wait until response timeout, before sending it, also freezing that part of the thread.

  So Go to you server's object CommandHandlers property, and select the onw which triggers with 'RINI', then go to the event OnCommand, and on it Write Asender.SendReply; and it shouldn't freeze on the next command you send.
  And here comes the ugly part: You must repeat the process for every command, if one doesn't have it (including the quit one), the client will not be able to process anything more (not even the disconnection).

  Other way to fix it is to set a Timeout, but, I wouldn't do it since Response time depends on the connection, and some may be very unstable.

Ohh, and by the way it freezes while procesing the TCPForm.IdTCPClient1.SendCmd('RDBNAMES'); line, instead of the following one, the trace doesn't show it, but the previous line stays trapped in a loop.
febalciAuthor Commented:
Thanks a lot,works fine now...

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now