SocketHandler and dropped connection.

Anton Fokin (kosu_fokin@garbo.lucas.lu.se)
Mon, 22 Mar 1999 19:22:53 +0100


Hello rooters and unixoids,

In my DAQ application I am following Rene suggestions to get use of
TFileHandler to handle TSocket activity :

class TSocketHandler: public TFileHandler {
private:
TSocket *Socket;
public:
TSocketHandler(TSocket *s);
Bool_t Notify();
Bool_t ReadNotify() {return Notify();}
TSocket *GetSocket() {return Socket;}

};

TSocketHandler::TSocketHandler(TSocket *s)
:TFileHandler(s->GetDescriptor(),1)
{
Socket=s;
gSystem->AddFileHandler(this);
}

Bool_t
TSocketHandler::Notify()
{
int data;
Socket->RecvRaw(&data,sizeof(data));
printf("received : %d\n",data);
return kTRUE;
}

Now we know from the roottalk that TSocket.RecvRaw() returns 0 if
server-client pipe is broken. That's the way to handle dropped connections
or other bad things. But could you tell me why TSocketHandler calls
Notify() (ReadNotify()) infinitely when I am dropping the connection on the
server side?

Yours,

Dr. Anton Fokin

Division of Cosmic and Subatomic Physics
Lund University
Sweden