ROOT logo
// @(#)root/net:$Id: TPSocket.h 23091 2008-04-09 15:04:27Z rdm $
// Author: Fons Rademakers   20/1/2001

/*************************************************************************
 * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TPSocket
#define ROOT_TPSocket


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TPSocket                                                             //
//                                                                      //
// This class implements parallel client sockets. A parallel socket is  //
// an endpoint for communication between two machines. It is parallel   //
// because several TSockets are open at the same time to the same       //
// destination. This especially speeds up communication over Big Fat    //
// Pipes (i.e. high bandwidth, high latency WAN connections).           //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TSocket
#include "TSocket.h"
#endif

class TMonitor;


class TPSocket : public TSocket {

friend class TPServerSocket;

private:
   TSocket   **fSockets;         // array of parallel sockets
   TMonitor   *fWriteMonitor;    // monitor write on parallel sockets
   TMonitor   *fReadMonitor;     // monitor read from parallel sockets
   Int_t       fSize;            // number of parallel sockets
   Int_t      *fWriteBytesLeft;  // bytes left to write for specified socket
   Int_t      *fReadBytesLeft;   // bytes left to read for specified socket
   char      **fWritePtr;        // pointer to write buffer for specified socket
   char      **fReadPtr;         // pointer to read buffer for specified socket

   TPSocket(TSocket *pSockets[], Int_t size);
   TPSocket(const TPSocket &);        // not implemented
   void operator=(const TPSocket &);  // idem
   void Init(Int_t tcpwindowsize, TSocket *sock = 0);
   Option_t *GetOption() const { return TObject::GetOption(); }

public:
   TPSocket(TInetAddress address, const char *service, Int_t size,
            Int_t tcpwindowsize = -1);
   TPSocket(TInetAddress address, Int_t port, Int_t size,
            Int_t tcpwindowsize = -1);
   TPSocket(const char *host, const char *service, Int_t size,
            Int_t tcpwindowsize = -1);
   TPSocket(const char *host, Int_t port, Int_t size, Int_t tcpwindowsize = -1);
   TPSocket(const char *host, Int_t port, Int_t size, TSocket *sock);
   virtual ~TPSocket();

   void          Close(Option_t *opt="");
   Int_t         GetDescriptor() const;
   TInetAddress  GetLocalInetAddress();

   Int_t   Send(const TMessage &mess);
   Int_t   Send(Int_t kind) { return TSocket::Send(kind); }
   Int_t   Send(Int_t status, Int_t kind) { return TSocket::Send(status, kind); }
   Int_t   Send(const char *mess, Int_t kind = kMESS_STRING) { return TSocket::Send(mess, kind); }
   Int_t   SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt);
   Int_t   Recv(TMessage *&mess);
   Int_t   Recv(Int_t &status, Int_t &kind) { return TSocket::Recv(status, kind); }
   Int_t   Recv(char *mess, Int_t max) { return TSocket::Recv(mess, max); }
   Int_t   Recv(char *mess, Int_t max, Int_t &kind) { return TSocket::Recv(mess, max, kind); }
   Int_t   RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt);

   Bool_t  IsValid() const { return fSockets ? kTRUE : kFALSE; }
   Int_t   GetErrorCode() const;
   Int_t   SetOption(ESockOptions opt, Int_t val);
   Int_t   GetOption(ESockOptions opt, Int_t &val);
   Int_t   GetSize() const { return fSize; }

   ClassDef(TPSocket,0)  // Parallel client socket
};

#endif
 TPSocket.h:1
 TPSocket.h:2
 TPSocket.h:3
 TPSocket.h:4
 TPSocket.h:5
 TPSocket.h:6
 TPSocket.h:7
 TPSocket.h:8
 TPSocket.h:9
 TPSocket.h:10
 TPSocket.h:11
 TPSocket.h:12
 TPSocket.h:13
 TPSocket.h:14
 TPSocket.h:15
 TPSocket.h:16
 TPSocket.h:17
 TPSocket.h:18
 TPSocket.h:19
 TPSocket.h:20
 TPSocket.h:21
 TPSocket.h:22
 TPSocket.h:23
 TPSocket.h:24
 TPSocket.h:25
 TPSocket.h:26
 TPSocket.h:27
 TPSocket.h:28
 TPSocket.h:29
 TPSocket.h:30
 TPSocket.h:31
 TPSocket.h:32
 TPSocket.h:33
 TPSocket.h:34
 TPSocket.h:35
 TPSocket.h:36
 TPSocket.h:37
 TPSocket.h:38
 TPSocket.h:39
 TPSocket.h:40
 TPSocket.h:41
 TPSocket.h:42
 TPSocket.h:43
 TPSocket.h:44
 TPSocket.h:45
 TPSocket.h:46
 TPSocket.h:47
 TPSocket.h:48
 TPSocket.h:49
 TPSocket.h:50
 TPSocket.h:51
 TPSocket.h:52
 TPSocket.h:53
 TPSocket.h:54
 TPSocket.h:55
 TPSocket.h:56
 TPSocket.h:57
 TPSocket.h:58
 TPSocket.h:59
 TPSocket.h:60
 TPSocket.h:61
 TPSocket.h:62
 TPSocket.h:63
 TPSocket.h:64
 TPSocket.h:65
 TPSocket.h:66
 TPSocket.h:67
 TPSocket.h:68
 TPSocket.h:69
 TPSocket.h:70
 TPSocket.h:71
 TPSocket.h:72
 TPSocket.h:73
 TPSocket.h:74
 TPSocket.h:75
 TPSocket.h:76
 TPSocket.h:77
 TPSocket.h:78
 TPSocket.h:79
 TPSocket.h:80
 TPSocket.h:81
 TPSocket.h:82
 TPSocket.h:83
 TPSocket.h:84
 TPSocket.h:85
 TPSocket.h:86
 TPSocket.h:87
 TPSocket.h:88
 TPSocket.h:89
 TPSocket.h:90