00001 // $Id: TGo4Socket.h 478 2009-10-29 12:26:09Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #ifndef TGO4SOCKET_H 00015 #define TGO4SOCKET_H 00016 00017 #include "Rtypes.h" 00018 00019 class TObject; 00020 class TSocket; 00021 class TServerSocket; 00022 class TGo4SocketSignalHandler; 00023 00024 class TGo4Socket { 00025 public: 00026 TGo4Socket(Bool_t IsClient); 00027 virtual ~TGo4Socket(); 00028 00029 virtual Int_t Open(const char* host, Int_t port, Bool_t keepservsock=kFALSE); 00030 virtual Int_t Close(Option_t *opt=""); 00031 00032 virtual Int_t Send(TObject *obj); 00033 virtual Int_t Send(const char* name); 00034 virtual TObject* Recv(const char* name=0); 00035 virtual char* RecvRaw(const char* name=0); 00036 00037 Bool_t IsOpen() const { return fbOpen; } 00038 00039 Bool_t IsClientMode() const { return fbClientMode; } 00040 00041 Int_t GetPort() const { return fiPort; } 00042 00048 Int_t SendBuffer(TBuffer* buf); 00049 00054 Int_t ReceiveBuffer(); 00055 00059 const TBuffer * GetBuffer() const { return fxBuffer; } 00060 00062 static const Int_t fguOPENWAIT; 00063 00065 static const Int_t fgiOPENCYCLES; 00066 00068 static const Int_t fgiBUFLENGTH; 00069 00071 static const Int_t fgiBUFINITSIZE; 00072 00074 static const Int_t fgiBUFEXTRASPACE; 00075 00077 static const char* fgcGOON; 00078 00080 static const Int_t fgiISOWNER; 00081 00082 protected: 00083 TGo4Socket(); // not implemented, only for compiler to avoid calling of default 00084 00086 void ReallocBuffer(TBuffer* buffer, Int_t oldsize, Int_t newsize); 00087 00088 private: 00089 00091 Bool_t fbClientMode; 00092 00094 Bool_t fbOpen; 00095 00098 TGo4SocketSignalHandler * fxSignalHandler; 00099 00101 TSocket * fxSocket; 00102 00104 TServerSocket * fxServerSocket; 00105 00107 Int_t fiPort; 00108 00109 char* fxLocalBuffer; 00110 00113 TBuffer * fxBuffer; 00114 }; 00115 00116 #endif