我在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