TSocket/TPSocket: Send more data than send/recv buffersizes

Yes, sure.

What I’m wondering is, whether I can store my data array in the TMessage directly, i.e., without putting it into a TObject-inheriting class before. I thought ReadArray/WriteArray would allow exactly this…

However, I’ve written a class doubly inheriting from TObject and TArrayC, which should hopefully work as the code example.

Hi again,

I’ve tried both ways now:
A class doubly inheriting from TObject and TArrayC (TObjTArrC.h in the attachment), and another one inheriting from TObject only, but wrapping a TArrayC (TObjTArrC2.h). The latter is modelled after TObjString.

I tried to follow the Adding Your Class to ROOT guide.

I adapted the example to send one of the aforementioned TObject-like Char_t arrays instead of a histogram.
Sadly, this fails with a segmentation violation on the receiving side, when I try to unpack the array.

I suspect the fact that mess->GetClass() is TObject and not TObjTArrC might point to the error, but don’t know whether/how this is set correctly.

Is there anything missing in the new class(es)?
Or did I break the example somehow?
_
sendobject.tar.gz (2.43 KB)

There is your ClassImp ?

Good question …
Do I need one? The manual says:

Or do you mean that there is only a header?
Are header-only libs not allowed in ROOT?

I could write one, but what should it do? All methods do trivial things?!

I’m not quite sure why you’re experiencing these problems with such a simple and basic task.
I have some advice (even if you have not asked me :slight_smile: ):

  1. Read the documentation and look at the sample code - ROOT has a lot of them and you have to know basics.
  2. If something does not work… try again. Again and again, find something working, try to understand why your code does not work and what’s the difference between working/non-working snippets and there’s exactly the problem in your code - that’s … an essential part of programming and debugging.

Now it took me 10 minutes to update hserv/hclient examples I’ve mentioned 3-4 or 5 times here and to modify them into something sending 1M bytes of data. I’m attaching this code here. Before you start the next round of “XXX does not work, YYY crashes, why?”, I have to say: my code perfectly works for me with ROOT 6 on OS X 10.10.4/ROOT 6 OpenSUSE 13.2 64-bit.

You do: in the server ROOT process:

// this will compile my class - container:
.L packet.cpp++
// this compiles the server:
.L hserv.C++
// this starts the server:
hserv()

On the sender’s/client’s side:

// compile container:
.L packet.cpp++
// compile the client
.L hclient.C++
// run the client and send the data.
hclient()

That is all.

Again, ROOT 6, OS X/OpenSUSE, if you have a different setup - it’s up to you to adopt the idea and debug your code.
hclient.C (298 Bytes)
hserv.C (701 Bytes)
packet.cpp (37 Bytes)
packet.h (563 Bytes)

[quote=“tpochep”]Now it took me 10 minutes to update hserv/hclient examples I’ve mentioned 3-4 or 5 times here and to modify them into something sending 1M bytes of data. I’m attaching this code here. Before you start the next round of “XXX does not work, YYY crashes, why?”, I have to say: my code perfectly works for me with ROOT 6 on OS X 10.10.4, I had no time to test this code/scenario somewhere else, let it be your exercise.

Again, ROOT 6, OS X, if you have a different setup - it’s up to you to adopt the idea and debug your code.[/quote]

Your code works for me, too. So, again thanks for that.

It turns out that my problem from yesterday is indeed the missing ClassImp, as you suggested. I added an empty one, as you did.

However, doesn’t this mean I simply took the documentation too literal? I mean there’s this line from the manual I quoted above that says ClassImp is not needed anymore.

So, now I know the ClassImp is needed despite the manual saying the opposite. However, I still don’t know why… An why the manual has that quoted line.

edit: It turns out the missing part was not the ClassImp (it is not needed, as the manual states), but an almost empty .cxx file that just #includes the .h of the new class. This needs to be compiled with .L as suggested above.

It looks like I can follow my own advice about reading the code and docs :slight_smile: - I do not think you need ClassImp anymore :slight_smile:

root.cern.ch/root/htmldoc/guide … Output.pdf

It’s never mentioned here, though they have a code sample containing ClassImp. And if you look at $ROOTSYS/include/RTypes.h you can see that ClassImp is quite trivial.

If you delete ClassImp from my code sample - you’ll see, it works (though you still have to compile Packet’s definition).

This might be a difference between ROOT 6 (yours) and 5 (mine). For me it segfaults (exactly like my code example) when I remove the ClassImp from your code.

OTOH, if I add it to my code the mess->GetClass() on the receiving side is correct (i.e., not only TObject).

edit: Sorry, spoke too soon.
Works perfectly without ClassImp as long as one compiles a .cxx that only #includes the .h.