library: libNetx #include "TXConnectionMgr.h"

# TXConnectionMgr

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

## class TXConnectionMgr : public TXAbsUnsolicitedMsgHandler, public TXUnsolicitedMsgSender

| Inheritance Chart:

`TXAbsUnsolicitedMsgHandler`
`TXUnsolicitedMsgSender`

<-

`TXConnectionMgr`

        private:

          virtual Bool_t ProcessUnsolicitedMsg(TXUnsolicitedMsgSender* sender, TXMessage* unsolmsg)
                    void RemoveLogConn(TXLogConnection*)
                    void RemovePhyConn(TXPhyConnection*)

        protected:

          void GarbageCollect()

        public:

                           TXConnectionMgr()
                           TXConnectionMgr(const TXConnectionMgr&)
                   virtual ~TXConnectionMgr()
            static TClass* Class()
                   Short_t Connect(TString RemoteAddress, Int_t TcpPort, Int_t TcpWindowSize)
                      void Disconnect(Short_t LogConnectionID, Bool_t ForcePhysicalDisc)
          TXLogConnection* GetConnection(Short_t LogConnectionID)
                     short GetPhyConnectionRefCount(TXPhyConnection* PhyConn)
                      void Init()
           virtual TClass* IsA() const
          TXConnectionMgr& operator=(const TXConnectionMgr&)
                TXMessage* ReadMsg(Short_t LogConnectionID, ESendRecvOptions opt = kDefault)
                     Int_t ReadRaw(Short_t LogConnectionID, void* buffer, Int_t BufferLength, ESendRecvOptions opt = kDefault)
              virtual void ShowMembers(TMemberInspector& insp, char* parent)
              virtual void Streamer(TBuffer& b)
                      void StreamerNVirtual(TBuffer& b)
                    Bool_t ThreadKilled() const
                     Int_t WriteRaw(Short_t LogConnectionID, const void* buffer, Int_t BufferLength, ESendRecvOptions opt = kDefault)

### Data Members

        private:

                            Bool_t fInitialized
          vector<TXLogConnection*> fLogVec
          vector<TXPhyConnection*> fPhyVec
                           TMutex* fMutex          mutex used to protect local variables
                          TThread* fThreadHandler
                            Bool_t fThreadKilled

## Class Description

     TXConnectionMgr

     Authors: Alvise Dorigo, Fabrizio Furano
              INFN Padova, 2003

     The Connection Manager handles socket communications for TXNetFile
     action: connect, disconnect, read, write. It is a static object of
     the TXNetFile class such that within a single application multiple
     TXNetFile objects share the same connection manager.
     The connection manager maps multiple logical connections on a single
     physical connection.
     There is one and only one logical connection per client (XNTetFile
     object), and one and only one physical connection per server:port.
     Thus multiple TXNetFile objects withing a given application share
     the same physical TCP channel to communicate with the server.
     This reduces the time overhead for socket creation and reduces also
     the server load due to handling many sockets.

TXConnectionMgr()

     TXConnectionMgr constructor.
     Used only to create the static instance when loading libNetx.

void Init()

     Full initialization of the TXConnectionMgr instance.
     Creates a Connection Manager object.
     Starts the garbage collector thread, if requested

~TXConnectionMgr()

     Deletes mutex locks, stops garbage collector thread.

void GarbageCollect()

     Get rid of unused physical connections. 'Unused' means not used for a
     TTL time from any logical one. The TTL depends on the kind of remote
     server. For a load balancer the TTL is very high, while for a data server
     is quite small.

void Disconnect(short int LogConnectionID, Bool_t ForcePhysicalDisc)

     Deletes a logical connection.
     Also deletes the related physical one if ForcePhysicalDisc=TRUE.

Int_t ReadRaw(short int LogConnectionID, void *buffer, Int_t BufferLength, ESendRecvOptions opt)

     Read BufferLength bytes from the logical connection LogConnectionID

TXMessage* ReadMsg(short int LogConnectionID, ESendRecvOptions opt)

Int_t WriteRaw(short int LogConnectionID, const void *buffer, Int_t BufferLength, ESendRecvOptions opt)

     Write BufferLength bytes into the logical connection LogConnectionID

TXLogConnection* GetConnection(short int LogConnectionID)

     Return a logical connection object that has LogConnectionID as its ID.

Bool_t ProcessUnsolicitedMsg(TXUnsolicitedMsgSender *sender, TXMessage *unsolmsg)

     We are here if an unsolicited response comes from a physical connection
     The response comes in the form of an TXMessage *, that must NOT be
     destroyed after processing. It is destroyed by the first sender.
     Remember that we are in a separate thread, since unsolicited responses
     are asynchronous by nature.

void RemoveLogConn(TXLogConnection *logc)

     Remove logc from the list of logical connections

void RemovePhyConn(TXPhyConnection *phyc)

     Remove phyc from the list of physical connections

### Inline Functions

                     Short_t Connect(TString RemoteAddress, Int_t TcpPort, Int_t TcpWindowSize)
                       short GetPhyConnectionRefCount(TXPhyConnection* PhyConn)
                      Bool_t ThreadKilled() const
                     TClass* Class()
                     TClass* IsA() const
                        void ShowMembers(TMemberInspector& insp, char* parent)
                        void Streamer(TBuffer& b)
                        void StreamerNVirtual(TBuffer& b)
             TXConnectionMgr TXConnectionMgr(const TXConnectionMgr&)
            TXConnectionMgr& operator=(const TXConnectionMgr&)

Author: Alvise Dorigo, Fabrizio Furano
Last update: root/netx:$Name: $:$Id: TXConnectionMgr.cxx,v 1.5 2005/05/08 13:49:31 rdm Exp $
Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *