#include "TError.h" #include "TMessage.h" #include "TServerSocket.h" #include "TSystem.h" #include "TThread.h" typedef struct { Int_t nseq; TSocket *sock; } thrdarg_t; // // Function to be run in the thread //___________________________________________________ void StartupThread(void *args) { thrdarg_t *arg = (thrdarg_t *)args; Int_t nseq = arg->nseq; TSocket *s = arg->sock; TMessage m; m << TString(Form("I am # %d",nseq)); s->Send(m); cout << gSystem->GetPid()<< ": thread "<< (Int_t *)TThread::Self() <<": sending: I am # "<IsValid()) { Info("MTSrv","waiting on port %d ...", port); while (1) { TSocket *s = fSSock->Accept(); if (s->IsValid()) { nsrv++; thrdarg_t *args = new thrdarg_t; args->nseq = nsrv; args->sock = s; TThread *t = new TThread((TThread::VoidFunc_t)StartupThread, (void *)args); t->Run(); } } } else { Info("MTSrv","could create the server socket"); } }