I am using the native-host in C++, when i send base64 from the native app to chrome extension(Native messaging) with size base64 < 1M, the program is still running. but when i send base64 from the native app to chrome extension (Native messaging) with size base64 >1M, the program is error "Error when communicating with the native messaging host" my code below
int _tmain(int argc, _TCHAR* argv[])
{
std::cout.setf( std::ios_base::unitbuf );
unsigned int c, t=0;
inp="";
t=0;
// Sum the first 4 chars from stdin (the length of the message passed).
for (int i = 0; i <= 3; i++) {
//t += getchar();
t += std::pow(256.0f, i) * getchar();
}
// Loop getchar to pull in the message until we reach the total
// length provided.
for (int i=0; i < t; i++) {
c = getchar();
inp += c;
}
unsigned int len = inp.length();
// We need to send the 4 btyes of length information
std::cout << char(((len>>0) & 0xFF))
<< char(((len>>8) & 0xFF))
<< char(((len>>16) & 0xFF))
<< char(((len>>24) & 0xFF));
// Now we can output our message
std::cout << inp;
return 0;
}