library: libCore #include "TMonitor.h"

# TMonitor

class description - source file - inheritance tree (.ps)

## class TMonitor : public TObject

| Inheritance Chart:

`TObject`

<-

`TMonitor`

        private:

          void SetReady(TSocket* sock)

        public:

                          TMonitor()
                          TMonitor(const TMonitor&)
                  virtual ~TMonitor()
                     void Activate(TSocket* sock)
                     void ActivateAll()
                     void Add(TSocket* sock, TMonitor::EInterest interest = kRead)
           static TClass* Class()
                     void DeActivate(TSocket* sock)
                     void DeActivateAll()
                    Int_t GetActive() const
                    Int_t GetDeActive() const
                   TList* GetListOfActives() const
                   TList* GetListOfDeActives() const
          virtual TClass* IsA() const
                TMonitor& operator=(const TMonitor&)
                     void Remove(TSocket* sock)
                     void RemoveAll()
                 TSocket* Select()
                 TSocket* Select(Long_t timeout)
             virtual void ShowMembers(TMemberInspector& insp, char* parent)
             virtual void Streamer(TBuffer& b)
                     void StreamerNVirtual(TBuffer& b)

### Data Members

        private:

            TList* fActive    list of sockets to monitor
            TList* fDeActive  list of (temporary) disabled sockets
          TSocket* fReady     socket which is ready to be read or written

        public:

          static const TMonitor::EInterest kRead
          static const TMonitor::EInterest kWrite

## Class Description

     TMonitor

     This class monitors activity on a number of network sockets.
     The actual monitoring is done by TSystem::DispatchOneEvent().
     Typical usage: create a TMonitor object. Register a number of
     TSocket objects and call TMonitor::Select(). Select() returns the
     socket object which has data waiting. TSocket objects can be added,
     removed, (temporary) enabled or disabled.

TMonitor()

     Create a monitor object.

~TMonitor()

     Cleanup the monitor object. Does not delete socket being monitored.

void Add(TSocket *sock, EInterest interest)

     Add socket to the monitor's active list. If interest=kRead then we
     want to monitor the socket for read readiness, if interest=kWrite
     then we monitor the socket for write readiness, if interest=kRead|kWrite
     then we monitor both read and write readiness.

void Remove(TSocket *sock)

     Remove a socket from the monitor.

void RemoveAll()

     Remove all sockets from the monitor.

void Activate(TSocket *sock)

     Activate a de-activated socket.

void ActivateAll()

     Activate all de-activated sockets.

void DeActivate(TSocket *sock)

     De-activate a socket.

void DeActivateAll()

     De-activate all activated sockets.

TSocket* Select()

     Return pointer to socket for which an event is waiting.

TSocket* Select(Long_t timeout)

     Return pointer to socket for which an event is waiting. Wait a maximum
     of timeout milliseconds. If return is due to timeout it returns
     (TSocket *)-1.

void SetReady(TSocket *sock)

     Called by TSocketHandler::Notify() to signal which socket is ready
     to be read. User should not call this routine. The ready socket will
     be returned via the Select() user function.

Int_t GetActive() const

     Return number of sockets in the active list.

Int_t GetDeActive() const

     Return number of sockets in the de-active list.

TList* GetListOfActives() const

     Returns a list with all active sockets. This list must be deleted
     by the user. DO NOT call Delete() on this list as it will delete
     the sockets that are still being used by the monitor.

TList* GetListOfDeActives() const

     Returns a list with all de-active sockets. This list must be deleted
     by the user. DO NOT call Delete() on this list as it will delete
     the sockets that are still being used by the monitor.

### Inline Functions

                TClass* Class()
                TClass* IsA() const
                   void ShowMembers(TMemberInspector& insp, char* parent)
                   void Streamer(TBuffer& b)
                   void StreamerNVirtual(TBuffer& b)
               TMonitor TMonitor(const TMonitor&)
              TMonitor& operator=(const TMonitor&)

Author: Fons Rademakers 09/01/97
Last update: root/net:$Name: $:$Id: TMonitor.cxx,v 1.5 2002/10/03 17:59:23 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *