Yes. Anything going beyond 2048 in your current code will be a buffer overflow - I thought you were studying that so that you could avoid it? Obviously didn't work.
Second, why not do:
Code:
char message[2049];
message[2048] = 0;
memset(message, '!', 2048);
// Optionally printf strlen(message).
Also, unless you also put a zero at the end of the receiving buffer and have enough space to receive ALL of the message, strlen() on the receiving side will continue until it finds a zero. Consider this:
Code:
char message[20000];
memset(message, '$', sizeof(message)-1);
message[sizeof(message)-1] = 0;
recv(acceptsock, message, 1024, 0);
printf("Message len = %d\n", strlen(message));
If you now recieve 1024 '!', then the message will contain 18975 '$', then a zero - so strlen is 20000. In your case, if you transmit 1024 or more bytes, strlen() will go outside the buffer.
--
Mats