19 #include <sys/types.h>
20 #include <sys/socket.h>
27 #include "TServerSocket.h"
31 #include "TGo4LockGuard.h"
43 #if ROOT_VERSION_CODE > ROOT_VERSION(4,3,2)
53 fbClientMode(IsClient),
61 GO4TRACE((14,
"TGo4Socket::TGo4Socket(Bool_t)", __LINE__, __FILE__));
80 GO4TRACE((14,
"TGo4Socket::~TGo4Socket()", __LINE__, __FILE__));
108 GO4TRACE((12,
"TGo4Socket::Open(const char* host, Int_t port)", __LINE__, __FILE__));
135 TGo4Log::Debug(
" Socket: Open(const char* host, Int_t port ) as Client failed ");
172 TGo4Log::Debug(
" Socket: Open(const char* host, Int_t port) as Server failed ");
228 GO4TRACE((12,
"TGo4Socket::Close()", __LINE__, __FILE__));
238 GO4TRACE((12,
"TGo4Socket::SendBuffer(TBuffer*)", __LINE__, __FILE__));
241 TGo4Log::Debug(
" !!! Socket: SendBuffer() ERROR : no buffer !!! ");
246 TGo4Log::Debug(
" !!! Socket: SendBuffer() ERROR : socket not open !!! ");
251 TGo4Log::Debug(
" !!! Socket: SendBuffer() ERROR : no TSocket !!! ");
256 UInt_t len = buf->Length();
257 char* field = buf->Buffer();
260 TGo4Log::Debug(
" !!! Socket: SendBuffer() ERROR : no data field !!! ");
265 tobuf(temp, (UInt_t)(len -
sizeof(UInt_t)));
277 Int_t rev = gSystem->SendRaw(
fxSocket->GetDescriptor(), field, len, MSG_NOSIGNAL);
279 Int_t rev =
fxSocket->SendRaw(field, len);
291 GO4TRACE((12,
"TGo4Socket::ReceiveBuffer()", __LINE__, __FILE__));
294 TGo4Log::Debug(
" !!! Socket: ReceiveBuffer() ERROR : not open !!! ");
299 TGo4Log::Debug(
" !!! Socket: ReceiveBuffer() ERROR : no TSocket !!! ");
306 Int_t rev = gSystem->RecvRaw(
fxSocket->GetDescriptor(), &len,
sizeof(UInt_t), MSG_NOSIGNAL);
308 Int_t rev =
fxSocket->RecvRaw(&len,
sizeof(UInt_t));
318 Int_t messlen = len +
sizeof(UInt_t);
321 Int_t oldsize =
fxBuffer->BufferSize();
322 Int_t newsize = messlen;
323 if(newsize>oldsize) {
328 if(newsize < TGo4Socket::fgiBUFINITSIZE)
333 char* buf =
fxBuffer->Buffer()+
sizeof(UInt_t);
336 rev = gSystem->RecvRaw(
fxSocket->GetDescriptor(), buf, len, MSG_NOSIGNAL);
338 rev =
fxSocket->RecvRaw((
void*) buf, len);
342 TGo4Log::Debug(
" !!! Socket: ReceiveBuffer() ERROR # %d !!! ",rev);
354 GO4TRACE((12,
"TGo4Socket::Send(TObject *obj)", __LINE__, __FILE__));
360 TMessage mess(kMESS_OBJECT);
363 mess.WriteObject(obj);
381 TGo4Log::Debug(
" !!! Socket: Send(TObject*) ERROR # %d !!! ",rev);
388 GO4TRACE((12,
"TGo4Socket::Send(const char* name)", __LINE__, __FILE__));
416 TGo4Log::Debug(
" !!! Socket: Send(const char*) ERROR # %d !!! ",rev);
424 GO4TRACE((12,
"TGo4Socket::RecvRaw(const char* name)", __LINE__, __FILE__));
427 TGo4Log::Debug(
" !!! Socket: Recv(const char*) ERROR : not open or not active !!! ");
432 TGo4Log::Debug(
" !!! Socket: Recv(const char*) ERROR : no TSocket !!! ");
443 TGo4Log::Debug(
" !!! Socket: RecvRaw(const char*) ERROR # %d !!! ",rev);
455 GO4TRACE((12,
"TGo4Socket::Recv(const char* name)", __LINE__, __FILE__));
473 if(mess->What() == kMESS_OBJECT)
475 obj = mess->ReadObject(mess->GetClass());
483 TGo4Log::Debug(
" !!! Socket: Recv(TMessage*) ERROR : no TSocket! ");
488 TGo4Log::Debug(
" !!! Socket: Recv(TMessage*) ERROR : not open or not active! ");
496 if(buffer==0)
return;
498 char* memfield = buffer->Buffer();
506 memfield = TStorage::ReAllocChar(memfield,
507 (newsize+extraspace),
508 (oldsize+extraspace));
514 buffer->SetBuffer(memfield, newsize);
522 buffer->SetBufferOffset(newsize);
virtual Int_t Close(Option_t *opt="")
static const Int_t fgiISOWNER
virtual Int_t Send(TObject *obj)
virtual TObject * Recv(const char *name=0)
Int_t SendBuffer(TBuffer *buf)
static const Int_t fgiOPENCYCLES
static const Int_t fguOPENWAIT
TServerSocket * fxServerSocket
virtual Int_t Open(const char *host, Int_t port, Bool_t keepservsock=kFALSE)
static const Int_t fgiBUFLENGTH
static const char * fgcGOON
static const Int_t fgiBUFINITSIZE
void ReallocBuffer(TBuffer *buffer, Int_t oldsize, Int_t newsize)
static void SetSigWINCH(Bool_t enabled=kTRUE)
virtual char * RecvRaw(const char *name=0)
static const Int_t fgiBUFEXTRASPACE
static void Debug(const char *text,...)
static void DisableSigPipe()