Correct me if I'm wrong.
struct st {
int a, b, c;
}
struct st test = {1, 2, 3};
send(socket, (char *) &test, sizeof(test), 0);
Now on the other side how should I receive it? Will something like this work:
struct st received;
read = recv(socket, (char *) & received, sizeof(st), 0);
The problem here is what if it doesn't read the whole structure at once, only some of the bytes(the amount is stored in read). Is the code below correct if I now want to append more bytes to this struct to read it completely?
recv(socket, (char *) &received + read, sizeof(st) - read, 0);
etc ? Of course this will go on until all bytes have been read.