Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:21

0001 // @(#)root/net:$Id$
0002 // Author: Fons Rademakers   20/1/2001
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TPSocket
0013 #define ROOT_TPSocket
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TPSocket                                                             //
0019 //                                                                      //
0020 // This class implements parallel client sockets. A parallel socket is  //
0021 // an endpoint for communication between two machines. It is parallel   //
0022 // because several TSockets are open at the same time to the same       //
0023 // destination. This especially speeds up communication over Big Fat    //
0024 // Pipes (i.e. high bandwidth, high latency WAN connections).           //
0025 //                                                                      //
0026 //////////////////////////////////////////////////////////////////////////
0027 
0028 #include "TSocket.h"
0029 
0030 class TMonitor;
0031 
0032 
0033 class TPSocket : public TSocket {
0034 
0035 friend class TPServerSocket;
0036 
0037 private:
0038    TSocket   **fSockets = nullptr;         // array of parallel sockets
0039    TMonitor   *fWriteMonitor = nullptr;    // monitor write on parallel sockets
0040    TMonitor   *fReadMonitor = nullptr;     // monitor read from parallel sockets
0041    Int_t       fSize;                      // number of parallel sockets
0042    Int_t      *fWriteBytesLeft = nullptr;  // bytes left to write for specified socket
0043    Int_t      *fReadBytesLeft = nullptr;   // bytes left to read for specified socket
0044    char      **fWritePtr = nullptr;        // pointer to write buffer for specified socket
0045    char      **fReadPtr = nullptr;         // pointer to read buffer for specified socket
0046 
0047    TPSocket(TSocket *pSockets[], Int_t size);
0048    TPSocket(const TPSocket &) = delete;
0049    void operator=(const TPSocket &) = delete;
0050    void Init(Int_t tcpwindowsize, TSocket *sock = nullptr);
0051    Option_t *GetOption() const override { return TObject::GetOption(); }
0052 
0053 public:
0054    TPSocket(TInetAddress address, const char *service, Int_t size,
0055             Int_t tcpwindowsize = -1);
0056    TPSocket(TInetAddress address, Int_t port, Int_t size,
0057             Int_t tcpwindowsize = -1);
0058    TPSocket(const char *host, const char *service, Int_t size,
0059             Int_t tcpwindowsize = -1);
0060    TPSocket(const char *host, Int_t port, Int_t size, Int_t tcpwindowsize = -1);
0061    TPSocket(const char *host, Int_t port, Int_t size, TSocket *sock);
0062    virtual ~TPSocket();
0063 
0064    void          Close(Option_t *opt="") override;
0065    Int_t         GetDescriptor() const override;
0066    TInetAddress  GetLocalInetAddress() override;
0067 
0068    Int_t   Send(const TMessage &mess) override;
0069    Int_t   Send(Int_t kind) override { return TSocket::Send(kind); }
0070    Int_t   Send(Int_t status, Int_t kind) override { return TSocket::Send(status, kind); }
0071    Int_t   Send(const char *mess, Int_t kind = kMESS_STRING) override { return TSocket::Send(mess, kind); }
0072    Int_t   SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt = kDefault) override;
0073    Int_t   Recv(TMessage *&mess) override;
0074    Int_t   Recv(Int_t &status, Int_t &kind) override { return TSocket::Recv(status, kind); }
0075    Int_t   Recv(char *mess, Int_t max) override { return TSocket::Recv(mess, max); }
0076    Int_t   Recv(char *mess, Int_t max, Int_t &kind) override { return TSocket::Recv(mess, max, kind); }
0077    Int_t   RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt = kDefault) override;
0078 
0079    Bool_t  IsValid() const override { return fSockets ? kTRUE : kFALSE; }
0080    Int_t   GetErrorCode() const;
0081    Int_t   SetOption(ESockOptions opt, Int_t val) override;
0082    Int_t   GetOption(ESockOptions opt, Int_t &val) override;
0083    Int_t   GetSize() const { return fSize; }
0084 
0085    ClassDefOverride(TPSocket,0)  // Parallel client socket
0086 };
0087 
0088 #endif