I am trying to get part of a package through recvfrom. It really works as follows:
recvfrom(sockfd, serialised_meta, 12, flags, src_addr, addrlen); recvfrom(sockfd, serialised_buf, BUFLEN, flags, src_addr, addrlen);
Data is sent as follows:
bufd->Serialise(serialised_buf, BUFLEN+12); sendto(sockfd, serialised_buf, BUFLEN+12, flags, dest_addr, addrlen);
So, the idea is to first read some metadata and then decide whether to receive anything else. The problem is that I get 4 '/ 0' bytes at the beginning if the second buffer (serialized_buf). This doesn't seem to be a serialization issue, I used to use serialization, and everything was cool, while I got the whole package (meta and data) at once. Any ideas on how to fix this?
PS. I understand that I can just skip unnecessary bytes) But anyway, why can this happen?
Roman source share