LOG(ERROR) << "Error when reading from Native Messaging host: " << result; Close(kHostInputOuputError);
LOG(ERROR) << "Native Messaging host tried sending a message that is " << message_size << " bytes long."; Close(kHostInputOuputError);
LOG(ERROR) << "Error when writing to Native Messaging host: " << result; Close(kHostInputOuputError);
Is there any way for me to see these LOG(ERROR) lines, to determine which it is?
I've stumbled upon at least one cause of this problem... Windows opens stdout in text mode by default. This means any time a \n (ASCII code 10) is outputted, an \r (ASCII code 13) will be outputted directly before it.
I ensure my JSON data contains no newlines, so the only place it was possible for that to happen was in the length field. Any time a message with a length whose binary representation included a 10 (for example, a 27146-byte message has a binary representation of 10,106,0,0) caused the problem to occur.
My solution is to change stdout's mode to binary:
setmode(fileno(stdout), O_BINARY);
--To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/1fd58d71-80df-4858-b3d3-47ffd666304a%40chromium.org.
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
Hi Drew,Thanks very much for following up. I thought I'd share an additional gotcha with text mode: The CRT will also stop reading in text mode when it encounters a ctrl-Z (0x1A). This won't occur in your JSON text, but if you send a JSON string that has a 1A as one of the bytes in the length (e.g. a 26-character length JSON message), your NativeHost will not receive any more input.GetStdHandle / ReadFile took care of this problem.Thanks!- Don
On Fri, Mar 7, 2014 at 9:27 AM, Drew <zit...@gmail.com> wrote:
Sounds likely... I'm using fread()/fwrite(), which do.
I should also mention that I had to set stdin to binary as well:
setmode(fileno(stdout), O_BINARY);
lest byte pairs 13,10 would be converted to 10.
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.