I'm sending a c struct with write to a server. The struct and write look like this.
typedef struct MyStruct {
    uint8_t         flag; 
    char            str[50];
    int32_t         number;
    time_t          time; 
} MyStruct ;
...
// Create mystruct
memset(&mystruct->flag,   '\1', sizeof(uint8_t));
memset(&mystruct->str, '\0', sizeof(char) * 50);
memset(&mystruct->number, '\2', sizeof(int32_t)); 
memset(&mystruct->time,   '\3', sizeof(time_t)); 
write(sockfd, mystruct, sizeof(MyStruct)); 
The server, in Java, receives the information in a nio ByteBuffer and then gets a byte[] with ByteBuffer.array. When I examine the byte[] its contents are:
[ 0]         = 1
[ 1] to [50] = 0
[51]         = 70
[52] to [55] = 2
[56] to [63] = 3
If you add the lengths up 1 + 50 + 4 + 8 you get 63, but the length with the odd 70 byte is 64.
Why is the 70 byte here? Does it have something to do with networking or c structs? Also how, if I can, get rid of it?
 
     
     
    