Hi,
I’m currently trying to amend a problem we are having with a piece of code that sends a raw data stream through a TSocket from a DAQ-PC to a PC where the data is analysed/displayed.
To do so, we are creating a buffer as char-array with the length prepended, and send the whole thing through TSocket::SendRaw(). On the other hand the length is read, a buffer is allocated, and then the remaining data is read.
After some analysing, I found that a problem occurs when the length of the buffer is larger than the send-/recv-buffer of the socket (hence also my other question here). In particular, data that does not fit into the send-/recv-buffer simply disappears… As far as I understand, this is the “correct” behaviour of TCP, however I obviously need to work against it. Strangely enough, it seems that this does not trigger the “would not block” return value (-4) of SendRaw()/RecvRaw().
When I first found ROOT’s parallel sockets TPSocket, I thought they should remedy the problem, as I was suspecting there would be some control mechanism in place to check if one of the parallel buffer is filled completely. However, this seems not to be the case. I simply increased the buffer size in the first line of the pclient.C example and found the same data loss as in the non-parallel case:
Processing pserv.C...
Receive 100 buffers of 50000000 bytes over 5 parallel sockets...
705032704 bytes received in 2.869882 seconds
234.16 MB/s
The second line should be reporting 5000000000 bytes …
This works however with a ten times smaller buffer:
Processing pserv.C...
Receive 100 buffers of 5000000 bytes over 5 parallel sockets...
500000000 bytes received in 0.500118 seconds
951.78 MB/s
To cut a long story short:
1.) Now, I’m wondering whether this is the intended behaviour of TPSocket? I had suspected that the data is sliced such that each slice fits into the respective send-/recv-buffers.
2.) What would be an advisable/reliable way to get this working?
I have come up with a function SendChunks() that cuts the buffer into pieces small enough to fit into the socket’s buffers, and then sends them piece by piece. However, I’m not sure how often I need to check for the buffer sizes, in order to stay in sync with TCP’s flow control…
3.) As mentioned above, how does one know when the data loss occurs, if the return value tells that everything worked fine?
Thanks in advance!
Sven