我在C++中使用本機主機時,當我從本機應用程序發送base64到基本大小爲64的Chrome擴展(本地消息傳遞)時,程序仍在運行。但是當我與大小的base64> 1M發送從本機應用程序的base64 Chrome瀏覽器擴展(本地消息),該計劃是錯誤的「錯誤與本地消息主機通信時」 我的代碼如下本地消息傳遞主機無法發送1 MB數據
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;
}
那麼,問題在哪裏?你想知道什麼? – 2014-12-02 13:54:57
是的,這是通過設計,他們根本不接受大於1M的消息。您需要將其分解爲一系列較小的消息,並重新組合擴展中的數據。 – donaddon 2014-12-02 15:28:05
@donaddon您是否有索賠來源? – Xan 2014-12-02 16:04:39