TPSocket.h

Go to the documentation of this file.
00001 // @(#)root/net:$Id: TPSocket.h 23091 2008-04-09 15:04:27Z rdm $
00002 // Author: Fons Rademakers   20/1/2001
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TPSocket
00013 #define ROOT_TPSocket
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TPSocket                                                             //
00019 //                                                                      //
00020 // This class implements parallel client sockets. A parallel socket is  //
00021 // an endpoint for communication between two machines. It is parallel   //
00022 // because several TSockets are open at the same time to the same       //
00023 // destination. This especially speeds up communication over Big Fat    //
00024 // Pipes (i.e. high bandwidth, high latency WAN connections).           //
00025 //                                                                      //
00026 //////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef ROOT_TSocket
00029 #include "TSocket.h"
00030 #endif
00031 
00032 class TMonitor;
00033 
00034 
00035 class TPSocket : public TSocket {
00036 
00037 friend class TPServerSocket;
00038 
00039 private:
00040    TSocket   **fSockets;         // array of parallel sockets
00041    TMonitor   *fWriteMonitor;    // monitor write on parallel sockets
00042    TMonitor   *fReadMonitor;     // monitor read from parallel sockets
00043    Int_t       fSize;            // number of parallel sockets
00044    Int_t      *fWriteBytesLeft;  // bytes left to write for specified socket
00045    Int_t      *fReadBytesLeft;   // bytes left to read for specified socket
00046    char      **fWritePtr;        // pointer to write buffer for specified socket
00047    char      **fReadPtr;         // pointer to read buffer for specified socket
00048 
00049    TPSocket(TSocket *pSockets[], Int_t size);
00050    TPSocket(const TPSocket &);        // not implemented
00051    void operator=(const TPSocket &);  // idem
00052    void Init(Int_t tcpwindowsize, TSocket *sock = 0);
00053    Option_t *GetOption() const { return TObject::GetOption(); }
00054 
00055 public:
00056    TPSocket(TInetAddress address, const char *service, Int_t size,
00057             Int_t tcpwindowsize = -1);
00058    TPSocket(TInetAddress address, Int_t port, Int_t size,
00059             Int_t tcpwindowsize = -1);
00060    TPSocket(const char *host, const char *service, Int_t size,
00061             Int_t tcpwindowsize = -1);
00062    TPSocket(const char *host, Int_t port, Int_t size, Int_t tcpwindowsize = -1);
00063    TPSocket(const char *host, Int_t port, Int_t size, TSocket *sock);
00064    virtual ~TPSocket();
00065 
00066    void          Close(Option_t *opt="");
00067    Int_t         GetDescriptor() const;
00068    TInetAddress  GetLocalInetAddress();
00069 
00070    Int_t   Send(const TMessage &mess);
00071    Int_t   Send(Int_t kind) { return TSocket::Send(kind); }
00072    Int_t   Send(Int_t status, Int_t kind) { return TSocket::Send(status, kind); }
00073    Int_t   Send(const char *mess, Int_t kind = kMESS_STRING) { return TSocket::Send(mess, kind); }
00074    Int_t   SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt);
00075    Int_t   Recv(TMessage *&mess);
00076    Int_t   Recv(Int_t &status, Int_t &kind) { return TSocket::Recv(status, kind); }
00077    Int_t   Recv(char *mess, Int_t max) { return TSocket::Recv(mess, max); }
00078    Int_t   Recv(char *mess, Int_t max, Int_t &kind) { return TSocket::Recv(mess, max, kind); }
00079    Int_t   RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt);
00080 
00081    Bool_t  IsValid() const { return fSockets ? kTRUE : kFALSE; }
00082    Int_t   GetErrorCode() const;
00083    Int_t   SetOption(ESockOptions opt, Int_t val);
00084    Int_t   GetOption(ESockOptions opt, Int_t &val);
00085    Int_t   GetSize() const { return fSize; }
00086 
00087    ClassDef(TPSocket,0)  // Parallel client socket
00088 };
00089 
00090 #endif

Generated on Tue Jul 5 14:28:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1