Select(timeout) ?

Krzysztof Zelazowski (Krzysztof.Zelazowski@cern.ch)
Fri, 19 Mar 1999 10:53:47 +0100


Dear ROOT users,

I would like to use TMonitor::Select(timeout) method, but it
seems as though I can't get it to do what I want.
Below, I have included a short piece of code that illustrates
my problem i.e. when I execute the m->Select(5000) the program
stops there until new socket's activity is detected, and doesn't
actually end the Select after the time-out. Why ?

ROOT 2.20/06, Solaris 5.6

Many thanks in advance for any comments.

Best regards,
Krzysztof

## Server #########################################################
{
TServerSocket *ss = new TServerSocket(9090,kTRUE);
TSocket *s=0;
s = ss->Accept();
TMonitor *m = new TMonitor();
m->Add(s);

TSocket *ns=0;
ns = m->Select(5000);

if (ns == (TSocket*) -1) {
printf("Time out.\n");
} else {
printf("Socket activity detected.\n");
}
}
## Client #########################################################

{
TSocket *s = new TSocket("localhost",9090);

//The Server does not end Select until s->Send(..) is called.
s->Send("HELLO");
}

_____________________________________________________________________
Krzysztof Wiktor Zelazowski Email: Krzysztof.Zelazowski@cern.ch
Etudiant technique div.EP |CERN| Tel.: +41 (22) 767 2382
_____________________________________________________________________