ROOT  6.06/09
Reference Guide
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 #ifndef ROOT_TSocket
29 #include "TSocket.h"
30 #endif
31 
32 class TMonitor;
33 
34 
35 class TPSocket : public TSocket {
36 
37 friend class TPServerSocket;
38 
39 private:
40  TSocket **fSockets; // array of parallel sockets
41  TMonitor *fWriteMonitor; // monitor write on parallel sockets
42  TMonitor *fReadMonitor; // monitor read from parallel sockets
43  Int_t fSize; // number of parallel sockets
44  Int_t *fWriteBytesLeft; // bytes left to write for specified socket
45  Int_t *fReadBytesLeft; // bytes left to read for specified socket
46  char **fWritePtr; // pointer to write buffer for specified socket
47  char **fReadPtr; // pointer to read buffer for specified socket
48 
49  TPSocket(TSocket *pSockets[], Int_t size);
50  TPSocket(const TPSocket &); // not implemented
51  void operator=(const TPSocket &); // idem
52  void Init(Int_t tcpwindowsize, TSocket *sock = 0);
53  Option_t *GetOption() const { return TObject::GetOption(); }
54 
55 public:
56  TPSocket(TInetAddress address, const char *service, Int_t size,
57  Int_t tcpwindowsize = -1);
58  TPSocket(TInetAddress address, Int_t port, Int_t size,
59  Int_t tcpwindowsize = -1);
60  TPSocket(const char *host, const char *service, Int_t size,
61  Int_t tcpwindowsize = -1);
62  TPSocket(const char *host, Int_t port, Int_t size, Int_t tcpwindowsize = -1);
63  TPSocket(const char *host, Int_t port, Int_t size, TSocket *sock);
64  virtual ~TPSocket();
65 
66  void Close(Option_t *opt="");
67  Int_t GetDescriptor() const;
69 
70  Int_t Send(const TMessage &mess);
71  Int_t Send(Int_t kind) { return TSocket::Send(kind); }
72  Int_t Send(Int_t status, Int_t kind) { return TSocket::Send(status, kind); }
73  Int_t Send(const char *mess, Int_t kind = kMESS_STRING) { return TSocket::Send(mess, kind); }
74  Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt);
75  Int_t Recv(TMessage *&mess);
76  Int_t Recv(Int_t &status, Int_t &kind) { return TSocket::Recv(status, kind); }
77  Int_t Recv(char *mess, Int_t max) { return TSocket::Recv(mess, max); }
78  Int_t Recv(char *mess, Int_t max, Int_t &kind) { return TSocket::Recv(mess, max, kind); }
79  Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt);
80 
81  Bool_t IsValid() const { return fSockets ? kTRUE : kFALSE; }
82  Int_t GetErrorCode() const;
84  Int_t GetOption(ESockOptions opt, Int_t &val);
85  Int_t GetSize() const { return fSize; }
86 
87  ClassDef(TPSocket,0) // Parallel client socket
88 };
89 
90 #endif
Int_t Recv(char *mess, Int_t max)
Receive a character string message of maximum max length.
Definition: TPSocket.h:77
char ** fReadPtr
Definition: TPSocket.h:47
const char Option_t
Definition: RtypesCore.h:62
char ** fWritePtr
Definition: TPSocket.h:46
ESockOptions
Definition: TSocket.h:52
virtual Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition: TSocket.cxx:520
virtual Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition: TSocket.cxx:818
Int_t Recv(Int_t &status, Int_t &kind)
Receives a status and a message type.
Definition: TPSocket.h:76
void Close(Option_t *opt="")
Close a parallel socket.
Definition: TPSocket.cxx:335
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:40
Int_t * fReadBytesLeft
Definition: TPSocket.h:45
Int_t Send(const TMessage &mess)
Send a TMessage object.
Definition: TPSocket.cxx:492
virtual ~TPSocket()
Cleanup the parallel socket.
Definition: TPSocket.cxx:317
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t Send(const char *mess, Int_t kind=kMESS_STRING)
Send a character string buffer.
Definition: TPSocket.h:73
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t Recv(char *mess, Int_t max, Int_t &kind)
Receive a character string message of maximum max length.
Definition: TPSocket.h:78
ESendRecvOptions
Definition: TSocket.h:65
#define ClassDef(name, id)
Definition: Rtypes.h:254
TSocket ** fSockets
Definition: TPSocket.h:40
TPSocket(TSocket *pSockets[], Int_t size)
Create a parallel socket. This ctor is called by TPServerSocket.
Definition: TPSocket.cxx:275
virtual Option_t * GetOption() const
Definition: TObject.h:129
TMonitor * fReadMonitor
Definition: TPSocket.h:42
Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt)
Send a raw buffer of specified length.
Definition: TPSocket.cxx:554
Double_t length(const TVector2 &v)
Definition: CsgOps.cxx:347
Option_t * GetOption() const
Definition: TPSocket.h:53
Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt)
Send a raw buffer of specified length.
Definition: TPSocket.cxx:688
void operator=(const TPSocket &)
Int_t Send(Int_t kind)
Send a single message opcode.
Definition: TPSocket.h:71
Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
Definition: TPSocket.cxx:763
Int_t GetSize() const
Definition: TPSocket.h:85
Int_t Send(Int_t status, Int_t kind)
Send a status and a single message opcode.
Definition: TPSocket.h:72
Int_t fSize
Definition: TPSocket.h:43
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
Definition: vector.h:440
TMonitor * fWriteMonitor
Definition: TPSocket.h:41
TInetAddress GetLocalInetAddress()
Return internet address of local host to which the socket is bound.
Definition: TPSocket.cxx:460
Int_t Recv(TMessage *&mess)
Receive a TMessage object.
Definition: TPSocket.cxx:635
Bool_t IsValid() const
Definition: TPSocket.h:81
Int_t * fWriteBytesLeft
Definition: TPSocket.h:44
Int_t GetErrorCode() const
Returns error code.
Definition: TPSocket.cxx:792
const Bool_t kTRUE
Definition: Rtypes.h:91
void Init(Int_t tcpwindowsize, TSocket *sock=0)
Create a parallel socket to the specified host.
Definition: TPSocket.cxx:365
Int_t GetDescriptor() const
Return socket descriptor.
Definition: TPSocket.cxx:476