I'm developing an application using Winsock in C++. I have a 200-byte-length char array for sending strings over the socket.
My problem is when sending messages which are larger than the char array, so I decided to send them in multiple chunks but I have no idea how to do it.
For sending and receiving the data, I'm using the regular send()
and recv()
functions:
recv(client, buffer, 200, NULL);
send(client, buffer, 200, NULL);
Update
I have a struct:
struct Pack
{
unsigned int senderId;
char str[200];
}
before sending I convert the struct
to char array.
Pack pk;
strcpy_s(pk.str, 200, "Some text to send.\0");
pk.senderId = 1 // user id
char *buffer = (char*)pk;
If the string size if larger than 200 the strcpy_s() crashes.