I am sending C ++ code that will transmit ie, receive and send messages on chrome extension. Hope this helps another developer.
int _tmain(int argc, _TCHAR* argv[])
{
cout.setf( std::ios_base::unitbuf );
_setmode(_fileno(stdin),_O_BINARY);
unsigned int c, i, t=0;
string inp;
bool bCommunicationEnds = false;
bool rtnVal = true;
do {
inp="";
t=0;
cin.read(reinterpret_cast<char*>(&t) ,4);
for (i=0; i < t; i++) {
c = getchar();
if(c == EOF)
{
bCommunicationEnds = true;
i = t;
}
else
{
inp += c;
}
}
if(!bCommunicationEnds)
{
cout.write(reinterpret_cast<char*>(&inp),4);
cout<<inp;
}
}while(!bCommunicationEnds);
return 0;
}
source
share