GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4Socket.h
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef TGO4SOCKET_H
15 #define TGO4SOCKET_H
16 
17 #include "RtypesCore.h"
18 
19 class TObject;
20 class TBuffer;
21 class TSocket;
22 class TServerSocket;
23 
24 class TGo4Socket {
25  public:
26  TGo4Socket(Bool_t IsClient);
27  virtual ~TGo4Socket();
28 
29  virtual Int_t Open(const char *host, Int_t port, Bool_t keepservsock = kFALSE);
30  virtual Int_t Close(Option_t *opt = "");
31 
32  virtual Int_t Send(TObject *obj);
33  virtual Int_t Send(const char *name);
34  virtual TObject *Recv(const char *name = nullptr);
35  virtual char *RecvRaw(const char *name = nullptr);
36 
37  Bool_t IsOpen() const { return fbOpen; }
38 
39  Bool_t IsClientMode() const { return fbClientMode; }
40 
41  Int_t GetPort() const { return fiPort; }
42 
48  Int_t SendBuffer(TBuffer *buf);
49 
54  Int_t ReceiveBuffer();
55 
59  const TBuffer *GetBuffer() const { return fxBuffer; }
60 
62  static const Int_t fguOPENWAIT;
63 
65  static const Int_t fgiOPENCYCLES;
66 
68  static const Int_t fgiBUFLENGTH;
69 
71  static const Int_t fgiBUFINITSIZE;
72 
74  static const Int_t fgiBUFEXTRASPACE;
75 
77  static const char *fgcGOON;
78 
79  protected:
80  TGo4Socket() = delete; // not implemented, only for compiler to avoid calling of default
81 
83  void ReallocBuffer(TBuffer *buffer, Int_t oldsize, Int_t newsize);
84 
85  private:
86 
88  Bool_t fbClientMode{kFALSE};
89 
91  Bool_t fbOpen{kFALSE};
92 
94  TSocket *fxSocket{nullptr};
95 
97  TServerSocket *fxServerSocket{nullptr};
98 
100  Int_t fiPort{0};
101 
102  char *fxLocalBuffer{nullptr};
103 
106  TBuffer *fxBuffer{nullptr};
107 };
108 
109 #endif
virtual Int_t Close(Option_t *opt="")
Definition: TGo4Socket.cxx:210
Bool_t IsOpen() const
Definition: TGo4Socket.h:37
TBuffer * fxBuffer
Definition: TGo4Socket.h:106
virtual Int_t Send(TObject *obj)
Definition: TGo4Socket.cxx:332
Int_t SendBuffer(TBuffer *buf)
Definition: TGo4Socket.cxx:220
TGo4Socket()=delete
static const Int_t fgiOPENCYCLES
Definition: TGo4Socket.h:65
static const Int_t fguOPENWAIT
Definition: TGo4Socket.h:62
virtual TObject * Recv(const char *name=nullptr)
Definition: TGo4Socket.cxx:431
TServerSocket * fxServerSocket
Definition: TGo4Socket.h:97
virtual Int_t Open(const char *host, Int_t port, Bool_t keepservsock=kFALSE)
Definition: TGo4Socket.cxx:92
static const Int_t fgiBUFLENGTH
Definition: TGo4Socket.h:68
TSocket * fxSocket
Definition: TGo4Socket.h:94
static const char * fgcGOON
Definition: TGo4Socket.h:77
Bool_t IsClientMode() const
Definition: TGo4Socket.h:39
Bool_t fbClientMode
Definition: TGo4Socket.h:88
Int_t GetPort() const
Definition: TGo4Socket.h:41
Int_t ReceiveBuffer()
Definition: TGo4Socket.cxx:273
virtual char * RecvRaw(const char *name=nullptr)
Definition: TGo4Socket.cxx:401
virtual ~TGo4Socket()
Definition: TGo4Socket.cxx:64
static const Int_t fgiBUFINITSIZE
Definition: TGo4Socket.h:71
void ReallocBuffer(TBuffer *buffer, Int_t oldsize, Int_t newsize)
Definition: TGo4Socket.cxx:461
Int_t fiPort
Definition: TGo4Socket.h:100
Bool_t fbOpen
Definition: TGo4Socket.h:91
static const Int_t fgiBUFEXTRASPACE
Definition: TGo4Socket.h:74
char * fxLocalBuffer
Definition: TGo4Socket.h:102
const TBuffer * GetBuffer() const
Definition: TGo4Socket.h:59