00001 // $Id: TGo4Socket.h 884 2012-11-10 16:47:22Z 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 00023 class TGo4Socket { 00024 public: 00025 TGo4Socket(Bool_t IsClient); 00026 virtual ~TGo4Socket(); 00027 00028 virtual Int_t Open(const char* host, Int_t port, Bool_t keepservsock=kFALSE); 00029 virtual Int_t Close(Option_t *opt=""); 00030 00031 virtual Int_t Send(TObject *obj); 00032 virtual Int_t Send(const char* name); 00033 virtual TObject* Recv(const char* name=0); 00034 virtual char* RecvRaw(const char* name=0); 00035 00036 Bool_t IsOpen() const { return fbOpen; } 00037 00038 Bool_t IsClientMode() const { return fbClientMode; } 00039 00040 Int_t GetPort() const { return fiPort; } 00041 00047 Int_t SendBuffer(TBuffer* buf); 00048 00053 Int_t ReceiveBuffer(); 00054 00058 const TBuffer * GetBuffer() const { return fxBuffer; } 00059 00061 static const Int_t fguOPENWAIT; 00062 00064 static const Int_t fgiOPENCYCLES; 00065 00067 static const Int_t fgiBUFLENGTH; 00068 00070 static const Int_t fgiBUFINITSIZE; 00071 00073 static const Int_t fgiBUFEXTRASPACE; 00074 00076 static const char* fgcGOON; 00077 00079 static const Int_t fgiISOWNER; 00080 00081 protected: 00082 TGo4Socket(); // not implemented, only for compiler to avoid calling of default 00083 00085 void ReallocBuffer(TBuffer* buffer, Int_t oldsize, Int_t newsize); 00086 00087 private: 00088 00090 Bool_t fbClientMode; 00091 00093 Bool_t fbOpen; 00094 00096 TSocket * fxSocket; 00097 00099 TServerSocket * fxServerSocket; 00100 00102 Int_t fiPort; 00103 00104 char* fxLocalBuffer; 00105 00108 TBuffer * fxBuffer; 00109 }; 00110 00111 #endif