User-defined data via the Client-Server connection


ROOT Version: 6.12
Platform: Centos 7
Compiler: gcc 6.2.0


Dear all,

I’m writing a small code quite similar to the tutorial example - tutorials/hserv.C hserv2.C hclient.C. Instead of sending a histogram, the target data is a vector of double derived from TObject:

Class Data : public TObject {
  public:
    ...
    const vector<double>& getData() const {return this->values;}
  private:
    vector<double> values;
};

On the sender side:

    vector<double> list(100, 99.);
    TServerSocket *ss = new TServerSocket(9090, kTRUE);
    TSocket *socket = ss->Accept();

    Data *sdata = new Data(move(list));

    TMessage mess(kMESS_OBJECT);
    mess.WriteObject(sdata);
    socket->Send(mess);

And on the receiver side:

    TSocket *socket = new TSocket("localhost",9090);
    TMessage *mess;

    socket->Recv(mess);

    Data *cdata = (Data *) mess->ReadObject(mess->GetClass());

    cdata->getData();

During runtime, the receiver side crashed with a segmentation violation:

Error in <TMessage::ReadClass>: illegal class tag=816318468 (0<tag<=1), I/O buffer corrupted
Error in <TMessage::ReadClass>: illegal class tag=816318468 (0<tag<=1), I/O buffer corrupted

 *** Break *** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f282385adbc in waitpid () from /lib64/libc.so.6
#1  0x00007f28237ddcc2 in do_system () from /lib64/libc.so.6
#2  0x00007f2827b55568 in TUnixSystem::StackTrace() () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.12.06-x86_64-slc6-gcc62-opt/lib/libCore.so
#3  0x00007f2827b57a6c in TUnixSystem::DispatchSignals(ESignals) () from /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.12.06-x86_64-slc6-gcc62-opt/lib/libCore.so
#4  <signal handler called>
#5  0x00000000004011dc in Data::getData() ()
#6  0x0000000000401044 in main ()
===========================================================

It seems the user object Data is not acceptable to TMessage, but all code examples I could find is to transfer histograms but no user defined objects. Should the data be derived from some specific class or it’s completely other issue?

Thanks in advance.

Hi,
Do you have a dictionary for the class Data?
Cheers, Axel.

Hi Axel,

Thanks for the tip. The dictionary was improperly linked.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.