?
Solved

idtcpclient problem

Posted on 2003-03-08
2
Medium Priority
?
1,292 Views
Last Modified: 2010-05-18
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?

begin
  TCPForm.IdTCPClient1.Host:=rHost_Address;
  TCPForm.IdTCPClient1.Port:=rHost_Port;
  try
   TCPForm.IdTCPClient1.Connect(5000);
  except
   on E : Exception do ShowMessage(E.Message);
  end;
  try
   rcvstr:=Tstringlist.Create;
   remoteinifile:=Tmeminifile.Create('');
   TCPForm.IdTCPClient1.SendCmd('RINI');
   TCPForm.IdTCPClient1.Readstrings(rcvstr,-1);
   remoteinifile.SetStrings(rcvstr);
   rInit_Sysaudit       := remoteinifile.ReadBool('INIT', 'SYSAUDIT',
False);
   rLogin_Optionsfolder := remoteinifile.ReadString('LOGIN',
'OPTIONSFOLDER', '');
   rDirectories_DefaultDir := remoteinifile.ReadString('DIRECTORIES',
'DEFAULTDIR', '');
  finally
   rcvstr.Free;
   remoteinifile.Free;
  end;
  try
   DBnames:=Tstringlist.Create;
   TCPForm.IdTCPClient1.SendCmd('RDBNAMES');
   
-->Freezing in the following line!

   TCPForm.IdTCPClient1.Readstrings(DBNames,-1);
   combobox1.items.addstrings(DBnames);
  finally
   DBNames.free;
  end;
end;

Thanks in advance,
0
Comment
Question by:febalci
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
Maximilianop earned 1200 total points
ID: 8099923
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.
0
 

Author Comment

by:febalci
ID: 8109814
Thanks a lot,works fine now...
0

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question