title: Node.js ReadLine not waiting for a full line on socket connections?
body: <p>I am trying to use <a href="http://nodejs.org/api/readline.html#readline_rl_prompt">Node.js's ReadLine</a> with <a href="http://nodejs.org/api/net.html#net_event_data">a socket</a>, like so:</p>
  
  <pre><code>var net = require('net');
  var rl = require('readline');
  
  this.streamServer = net.createServer(function (socket) {
      var i = rl.createInterface(socket, socket);
      i.on('line', function (line) {
          socket.write(line);
      });
  });
  this.streamServer.maxConnections = 1;
  this.streamServer.listen(7001);
  </code></pre>
  
  <p>When I telnet into port 7001 and start typing text, it is immediately echoed back to me before I ever push enter.</p>
  
  <p><strong>Why is ReadLine not waiting for a full line?</strong></p>
  
  <p>I have also tried <a href="http://nodejs.org/api/readline.html#readline_rl_question_query_callback"><code>.question()</code></a> and I get the same results...  The callback is fired upon reception of any data, without waiting for an end-of-line character.</p>
  
  <hr>
  
  <p><strong>Edit:</strong> This gets even stranger.  When I test using the Windows telnet client, I get the behavior that I stated above.  However, if I test using PuTTY as the client, ReadLine works, even on Windows.  I did some packet captures.  Maybe someone could shed some light on this?  Unindented lines are data from the client. Indented lines are the server replies.</p>
  
  <p><strong>Using Windows Telnet</strong></p>
  
  <pre><code>00000000  61                                               a
      00000000  61                                               a
  00000001  62                                               b
      00000001  62                                               b
  00000002  63                                               c
      00000002  63                                               c
  00000003  64                                               d
      00000003  64                                               d
  00000004  65                                               e
      00000004  65                                               e
  00000005  66                                               f
      00000005  66                                               f
  00000006  67                                               g
      00000006  67                                               g
  00000007  68                                               h
      00000007  68                                               h
  00000008  69                                               i
      00000008  69                                               i
  00000009  6a                                               j
      00000009  6a                                               j
  0000000A  6b                                               k
      0000000A  6b                                               k
  0000000B  6c                                               l
      0000000B  6c                                               l
  0000000C  6d                                               m
      0000000C  6d                                               m
  0000000D  6e                                               n
      0000000D  6e                                               n
  0000000E  6f                                               o
      0000000E  6f                                               o
  0000000F  70                                               p
      0000000F  70                                               p
  00000010  0d 0a                                            ..
      00000010  0d 0a                                            ..
  00000012  0d 0a                                            ..
      00000012  0d 0a                                            ..
  00000014  0d 0a                                            ..
      00000014  0d 0a                                            ..
  00000016  61                                               a
      00000016  61                                               a
  00000017  73                                               s
      00000017  73                                               s
  00000018  64                                               d
      00000018  64                                               d
  00000019  66                                               f
      00000019  66                                               f
  0000001A  0d 0a                                            ..
      0000001A  0d 0a                                            ..
  0000001C  61                                               a
      0000001C  61                                               a
  0000001D  73                                               s
      0000001D  73                                               s
  0000001E  64                                               d
      0000001E  64                                               d
  0000001F  66                                               f
      0000001F  66                                               f
  00000020  0d 0a                                            ..
      00000020  0d 0a                                            ..
  </code></pre>
  
  <p><strong>Using PuTTY</strong></p>
  
  <pre><code>00000000  ff fb 1f ff fb 20 ff fb  18 ff fb 27 ff fd 01 ff ..... .. ...'....
  00000010  fb 03 ff fd 03                                   .....
      00000000  ef bf bd ef bf bd 1f ef  bf bd ef bf bd 20 ef bf ........ ..... ..
      00000010  bd ef bf bd 18 ef bf bd  ef bf bd 27 ef bf bd ef ........ ...'....
      00000020  bf bd 01 ef bf bd ef bf  bd 03 ef bf bd ef bf bd ........ ........
      00000030  03                                               .
  00000015  61 62 63 64 65 66 67                             abcdefg
  0000001C  0d 0a                                            ..
      00000031  61 62 63 64 65 66 67                             abcdefg
      00000038  0d 0a                                            ..
  0000001E  61 73 64 66                                      asdf
  00000022  0d 0a                                            ..
      0000003A  61 73 64 66                                      asdf
      0000003E  0d 0a                                            ..
  00000024  61 73 64 66                                      asdf
  00000028  0d 0a                                            ..
      00000040  61 73 64 66                                      asdf
      00000044  0d 0a                                            ..
  0000002A  0d 0a                                            ..
      00000046  0d 0a                                            ..
  </code></pre>