title: Node.js TCP server incoming buffer
body: <p>I have two node processes that speak to each other.  I will call them <strong>[Node Server]</strong> and <strong>[Node Sender]</strong>.  <strong>[Node Sender]</strong> continually processes information and writes a message over a TCP connection to <strong>[Node Server]</strong>.  <strong>[Node Server]</strong> then writes back a status message.</p>
  
  <p>Example of [Node Sender]:</p>
  
  <pre><code>var message = "Test Message";
  [Node Sender].connection.write(message);
  </code></pre>
  
  <p>Example of [Node Server]:</p>
  
  <pre><code>[Node Server].socket.on("data", function(p_data) {
      this.write("OK");
  
      // Do some work with p_data
  }
  </code></pre>
  
  <p>This works without issue, <strong>p_data</strong> always contains <em>"Test Message"</em> when sent at anything above 5 milliseconds.  However, if I speed <strong>[Node Sender]</strong> to write every millisecond, <strong>p_data</strong> occasionally ends up with something like <em>"Test MessageTest MessageTes"</em>.</p>
  
  <p>I understand that the buffer in <strong>[Node Sender]</strong> is probably filling faster than the write command is sending it.  Is there a way to force a one-to-one ratio in sending messages while still remaining asynchronous?  </p>
  
  <p>I can certainly just add a terminator to my message and just fill a buffer in <strong>[Node Server]</strong>, but I wanted to make sure there wasn't something obvious I was missing.</p>