//
//
// Logs:
//
//  $Log: TLServer.h,v $
//  Revision 1.4  2003/11/03 13:54:40  cvs
//  TLServer is now threaded, LData and LDataHeader have now right Draw and Paint methods, LIV is controlled and comments were added.
//
//  Revision 1.3  2003/08/20 10:26:51  cvs
//  Added scripts directory with two utilities now:
//  modify_header which modify existing header and send it database
//  deliver_header program and script which deliver header to clients
//
//  libLComm was made ROOT compatible and GetBias(z) was added to LDataHeader
//
//  Revision 1.2  2003/06/26 09:27:11  cvs
//  added log fields...
//
#ifndef __TLServer_h
#define __TLServer_h

#include "TServerSocket.h"
#include "LClientTypes.h"
#include "TMonitor.h"
#include "TThread.h"
#include <queue>

class TLServer : public TServerSocket {
 private:
  TSocket *fSocket[kLC_MAX];               // main sockets
  TSocket *fASocket[kLC_AMAX-kLC_MAX-1];   // monitoring sockets
  TSocket *fS;      //current socket                       
  TMonitor* fMon;
  TMessage* fMess;
  std::queue<TMessage*> fMessQueue[kLC_AMAX][kLC_AMAX]; // message queue
  Bool_t fWaitingClient[kLC_AMAX][kLC_AMAX];       // flags for reading clients
  UInt_t fNMaxMess;  // Maximum number of messages in each queue

  TThread* pmThread[kLC_AMAX]; //pointer to thread

 public:
  TLServer(const Int_t port,Bool_t reuse=kTRUE, const UInt_t maxmess=10);
  ~TLServer();
  //  Bool_t Connect(const ELClientTypes elc);
  //  Bool_t AConnect();
  void Listen();        // main loop
 private:
  TSocket* Connect(TSocket* s,TLServer* inst);
  static void Thread_func(void* arg);
  void Thread_stop(int num=-1);
  ClassDef(TLServer,0)  //Networking server 
};


#endif //__TLServer_h
