I am connecting to my local bitcoind using TCP and observed the following behavior:
I see many messages where only header is given or only part of the payload is attached. Of course, it could be a bug my code too.
Are the bytes sent in chunks? Which of the following are valid?
|header1|payload1| (as per documentation, this is valid) |header1| (no payload, even though required. Have seen this) |payload1| (no header, have seen this) |header1|partPayload1| (incomplete payload, not sure if seen these) |partPayload1| (part earlier header's payload, not sure if seen these) |header1|payload1|header2|payload2| |header1|payload1|header2|partPayload2| |header1|partPayload1|header2| |partPayload1|header2|payload2|
Note: I am using version number 70002, relay = 1 and services = 0.
EDIT: Generally I wait for the remaining bytes, and most of the times they arrive, but in rare cases, around 2%, some other header arrives. This happens only with
EDIT2: Based on the comments below, it seems likely that there is a bug in my code. I'll check and revert.
EDIT3: Was a bug in my code. I was assuming that partial data packets correspond to a single header. There can be multiple headers after the data is complete (in the same packet). This makes sense once I consider it as a stream.