GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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
19class TObject;
20class TBuffer;
21class TSocket;
22class TServerSocket;
23
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
char * fxLocalBuffer
Definition TGo4Socket.h:102
Int_t ReceiveBuffer()
Receive raw buffer and fill the internal TBuffer of this socket instance with it.
Bool_t fbOpen
True if connection is open.
Definition TGo4Socket.h:91
TServerSocket * fxServerSocket
Server Socket (server mode only)
Definition TGo4Socket.h:97
static const Int_t fguOPENWAIT
Time to sleep between client open retries.
Definition TGo4Socket.h:62
Bool_t IsOpen() const
Definition TGo4Socket.h:37
static const Int_t fgiBUFINITSIZE
Initial size for object receive buffer (TBuffer)
Definition TGo4Socket.h:71
TSocket * fxSocket
root TSocket class doing the work
Definition TGo4Socket.h:94
Int_t GetPort() const
Definition TGo4Socket.h:41
virtual Int_t Send(TObject *obj)
virtual ~TGo4Socket()
virtual Int_t Close(Option_t *opt="")
static const Int_t fgiBUFEXTRASPACE
ROOT internal constant: extra space for reallocating object receive buffer (TBuffer)
Definition TGo4Socket.h:74
static const Int_t fgiBUFLENGTH
Raw transport buffer size.
Definition TGo4Socket.h:68
TGo4Socket(Bool_t IsClient)
const TBuffer * GetBuffer() const
Access the internal receiving buffer of this socket.
Definition TGo4Socket.h:59
virtual Int_t Open(const char *host, Int_t port, Bool_t keepservsock=kFALSE)
virtual TObject * Recv(const char *name=nullptr)
Bool_t IsClientMode() const
Definition TGo4Socket.h:39
Bool_t fbClientMode
True if instance runs in as client.
Definition TGo4Socket.h:88
static const char * fgcGOON
First connection string, we are told to go on...
Definition TGo4Socket.h:77
static const Int_t fgiOPENCYCLES
Number of retries for client open.
Definition TGo4Socket.h:65
TGo4Socket()=delete
TBuffer * fxBuffer
aggregation 1
Definition TGo4Socket.h:106
Int_t SendBuffer(TBuffer *buf)
Send raw buffer of external TBuffer object.
Int_t fiPort
Connected port number (of server socket which opened with portnumberscan)
Definition TGo4Socket.h:100
void ReallocBuffer(TBuffer *buffer, Int_t oldsize, Int_t newsize)
Reallocate the fixed input buffer if necessary.
virtual char * RecvRaw(const char *name=nullptr)