Hi Andreas,
I'll make the proposed changes.
Cheers, Fons.
Andreas Zoglauer wrote:
>
> Hi Fons,
>
> On Wed, 25 Apr 2001, Fons Rademakers wrote:
> > could you change TUnixSystem::OpenConnection and use something like
> > Sleep(250). Or without sleep at all. If that is acceptable let me know
> > then I change it in CVS.
>
> I tested it between two Systems on our internal network with the tutorial
> macros hclient.C and hserv.C with the following code:
>
> //______________________________________________________________________________
> int TUnixSystem::OpenConnection(const char *server, int port, int
> tcpwindowsize)
> {
> // Open a connection to a service on a server. Try 3 times with an
> // interval of 1 second.
> // Use tcpwindowsize to specify the size of the receive buffer, it has
> // to be specified here to make sure the window scale option is set (for
> // tcpwindowsize > 65KB and for platforms supporting window scaling).
> // Is called via the TSocket constructor.
>
> int attempts = 3;
> for (int i = 0; i < attempts; i++) {
> Warning("", "Attempt: %d", i);
> int fd = ConnectService(server, port, tcpwindowsize);
> if (fd >= 0)
> return fd;
> if (i < attempts-1) {
> Sleep(250);
> }
> }
> return -1;
> }
>
> As long as the server was running, there was always a connection after
> the first attempt - so the Sleep-command was only reached when a
> connection was impossible, because the server was not running - this is
> the case I have to cope with in my program.
>
> If there are some good reasons not to change the default behaviour, we
> should try something like:
>
> In TSystem and TUnixSystem:
> OpenConnection(const char *server, int port, int
> tcpwindowsize = -1, int attempts = 3)
>
> int TUnixSystem::OpenConnection(const char *server, int port, int
> tcpwindowsize, int attempts) {
> // Open a connection to a service on a server. Try 3 times with an
> // interval of 1 second.
> // Use tcpwindowsize to specify the size of the receive buffer, it has
> // to be specified here to make sure the window scale option is set (for
> // tcpwindowsize > 65KB and for platforms supporting window scaling).
> // Is called via the TSocket constructor.
>
> for (int i = 0; i < attempts; i++) {
> int fd = ConnectService(server, port, tcpwindowsize);
> if (fd >= 0)
> return fd;
> if (i < attemps-1) {
> Sleep(1000);
> }
> }
> return -1;
> }
>
> With this changes I can derive my own Socket class and can avoid any
> unnecessary wait cycles when the server is not running.
>
> Andreas
>
> ----------------------------------------------------------------------
> 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
> ----------------------------------------------------------------------
--
Org: CERN, European Laboratory for Particle Physics.
Mail: 1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch Phone: +41 22 7679248
WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:43 MET