Hello,
I would appreciate any suggestions. I have a client and server program. The server writes a struct to a socket:
Code:
struct packet
{
int seq;
int type;
int size;
char data[1024];
unsigned long int checksum;
};
the server writes a struct to the socket as a long array of chars 1034 bytes long...
now the client reads the packet into a char buffer i've allocated.
now i want to parse all the respective fields from the buffer. i am thinking of using:
Code:
struct packet current;
sscanf(buffer, " %i %i %i %1024c %uli", ¤t.seq, ¤t.type, ¤t.size, current.data, ¤t.checksum);
will/should this work in the way i have it written? i tried it this was and read FFFFFFFF for size, and for the data as well. don't quite know why.
i know that i could do a series of memcpy's to copy the fields, but is there any easier way to do this?
thanks in advance!!