title: Node.js reply tcp server
body: <p>I am trying to create a simple reply server in node.js</p>
  
  <p>The problem I am having, is that when I telnet into the server, and send a hello, the if loop doesn't catch it, and it goes to the else.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>var net = require('net');
  
  var server = net.createServer(function(socket) {
  // Server start
  socket.write('Welcome\n');
  
  socket.on('data', function(data) {
  
          dataReceived(socket, data);
      }); 
  
  });
  
  server.listen(8250);
  
  function dataReceived(socket, data) {
      if(data == 'hello') {
      socket.end('Hi');
      } else {
      socket.write(data);
      socket.end('what??\n');
  }
  }
  </code></pre>
  
  <p>Thanks.</p>