Click to See Complete Forum and Search --> : Socket question, can someone please help me ????


October 28th, 1999, 12:52 PM
Hi,
If variable 'b' is a type of struct, say

struct data {
char packet[32];
int alert;
};
....
data *b;
what function from the winsock library can I use to send b to a remote client or server ??? CAN SOMEONE PLEASE HELP ME ??

October 29th, 1999, 01:46 AM
1) memcpy that struct into a char buffer:
char *buf = (char *)malloc(sizeof(data));
memcpy(buf, &b, sizeof(data);
send(socket, buf, sizeof(data), 0);

or
2) typecast to char *
send(socket, (char *)&b, sizeof(data), 0);