Code:
int STRLEN = 512;
char recMessage[STRLEN] = "0";
This is not valid C++ code.

Also, the error message says you have a buffer overrun.