[ROOT] Time consumption in MSocket constructor

From: Andreas Zoglauer (zog@mpe.mpg.de)
Date: Wed Apr 25 2001 - 18:13:55 MEST


Hi ROOTers,

I implemented an application using client-server communication via the 
classes MSocket and MServerSocket.

I implemented some routines to detect if one of the programs is not 
running e.g. the server. In this case the client frequently tries to 
reconnect to the server. This reconnection is done via creating a new 
TSocket object.

Until the program returns from a call like

>  TSocket *S = new TSocket("localhost, 9090);

almost 3 seconds have passed - in case the connection was not possible.


The reason for this lies in the function 
TUnixSystem::OpenConnection(...)
{
   ...

   for (int i = 0; i < 3; i++) {
      int fd = ConnectService(server, port, tcpwindowsize);
      if (fd >= 0)
         return fd;
      sleep(1);
   }
}

Now my questions regarding the above code:

* Is it really necessary to try 3 times to connect?

* Is it really necessary to sleep for one second?

Yes, one second, I tested it. A call to gSystem->Sleep(1) would take only 
one millisecond, but sleep(1) takes ONE second.

This high time consumption is very unfavorable, because I try to build a 
real-time analysis tool.

The attempt to bypass OpenConnection and call directly ConnectService 
from a class dervied from TSocket failed because there is no class 
ConnectService in TSystem (only in TUnixSystem).


If nobody suggest another possiblity I will simply copy the source-code 
from TUnixSystem to my Socket-class, but if possible I would like to 
prevent this...



Thanks,

Andreas


ROOT-version: 3.00.06, OS: SuSE Linux 7.1



----------------------------------------------------------------------
Andreas Zoglauer

MPI fuer extraterrestrische Physik         Phone:    +49/89-30000-3848
Postfach 1312                              Fax:      +49/89-30000-3569
85741 Garching, Germany                    Email:    zog@mpe.mpg.de
----------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:43 MET