Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TPSocket.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Fons Rademakers 20/1/2001
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TPSocket
13 #define ROOT_TPSocket
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TPSocket //
19 // //
20 // This class implements parallel client sockets. A parallel socket is //
21 // an endpoint for communication between two machines. It is parallel //
22 // because several TSockets are open at the same time to the same //
23 // destination. This especially speeds up communication over Big Fat //
24 // Pipes (i.e. high bandwidth, high latency WAN connections). //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #include "TSocket.h"
29 
30 class TMonitor;
31 
32 
33 class TPSocket : public TSocket {
34 
35 friend class TPServerSocket;
36 
37 private:
38  TSocket **fSockets; // array of parallel sockets
39  TMonitor *fWriteMonitor; // monitor write on parallel sockets
40  TMonitor *fReadMonitor; // monitor read from parallel sockets
41  Int_t fSize; // number of parallel sockets
42  Int_t *fWriteBytesLeft; // bytes left to write for specified socket
43  Int_t *fReadBytesLeft; // bytes left to read for specified socket
44  char **fWritePtr; // pointer to write buffer for specified socket
45  char **fReadPtr; // pointer to read buffer for specified socket
46 
47  TPSocket(TSocket *pSockets[], Int_t size);
48  TPSocket(const TPSocket &); // not implemented
49  void operator=(const TPSocket &); // idem
50  void Init(Int_t tcpwindowsize, TSocket *sock = 0);
51  Option_t *GetOption() const { return TObject::GetOption(); }
52 
53 public:
54  TPSocket(TInetAddress address, const char *service, Int_t size,
55  Int_t tcpwindowsize = -1);
56  TPSocket(TInetAddress address, Int_t port, Int_t size,
57  Int_t tcpwindowsize = -1);
58  TPSocket(const char *host, const char *service, Int_t size,
59  Int_t tcpwindowsize = -1);
60  TPSocket(const char *host, Int_t port, Int_t size, Int_t tcpwindowsize = -1);
61  TPSocket(const char *host, Int_t port, Int_t size, TSocket *sock);
62  virtual ~TPSocket();
63 
64  void Close(Option_t *opt="");
65  Int_t GetDescriptor() const;
66  TInetAddress GetLocalInetAddress();
67 
68  Int_t Send(const TMessage &mess);
69  Int_t Send(Int_t kind) { return TSocket::Send(kind); }
70  Int_t Send(Int_t status, Int_t kind) { return TSocket::Send(status, kind); }
71  Int_t Send(const char *mess, Int_t kind = kMESS_STRING) { return TSocket::Send(mess, kind); }
72  Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt);
73  Int_t Recv(TMessage *&mess);
74  Int_t Recv(Int_t &status, Int_t &kind) { return TSocket::Recv(status, kind); }
75  Int_t Recv(char *mess, Int_t max) { return TSocket::Recv(mess, max); }
76  Int_t Recv(char *mess, Int_t max, Int_t &kind) { return TSocket::Recv(mess, max, kind); }
77  Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt);
78 
79  Bool_t IsValid() const { return fSockets ? kTRUE : kFALSE; }
80  Int_t GetErrorCode() const;
81  Int_t SetOption(ESockOptions opt, Int_t val);
82  Int_t GetOption(ESockOptions opt, Int_t &val);
83  Int_t GetSize() const { return fSize; }
84 
85  ClassDef(TPSocket,0) // Parallel client socket
86 };
87 
88 #endif