I have two node processes that talk to each other. I will name them [Node Server] and [Node Sender] . [Node Sender] constantly processes information and writes a message over a TCP connection to [Node Server] . [Node Server] , then write a status message.
Example [Node Sender]:
var message = "Test Message"; [Node Sender].connection.write(message);
Example [Node Server]:
[Node Server].socket.on("data", function(p_data) { this.write("OK");
This works without problems, p_data strong> always contains a "test message" when sending to anything more than 5 milliseconds. However, if I speed [Node Sender] to write every millisecond, p_data strong> sometimes ends with something like "Test MessageTest MessageTes".
I understand that the buffer in [Node Sender] is probably filling up faster than the write command sends it. Is there a way to force a one-to-one ratio when sending messages while remaining asynchronous?
Of course, I can simply add a terminator to my message and simply fill the buffer in [Node Server] , but I wanted to make sure that there was something obvious that I was missing.
user747454
source share