title: nodejs JSON.parse(data_from_TCP_socket)
body: <p>I have this code at nodejs server that is working with require('net'), so it is TCP, client side is AS3 and sending data correctly:</p>
  
  <pre><code>var server = net.createServer(function(socket) {
  
      socket.setEncoding("utf8");
      clients.push(socket);   
  
      function broadcast(message) {
          clients.forEach(function (client) {
              client.write(message);
          });
      }
  
      socket.on('data', function(dt){
          var rdt = dt;
          var srdt = rdt.toString();
          var ordt = JSON.parse(srdt);
          console.log(ordt);
          broadcast(ordt);
      }); 
  
      socket.on('end', function(){...});
  })
  </code></pre>
  
  <p>It can not parse the data and give all kinds of errors. The thing I could understand that I get "buffer" from the client. But I need to keep sockets opened, so common solutions with looping buffer won't work for me.</p>
  
  <p>Please help me to solve this.</p>
  
  <p>BTW, client that stringifies the data, when receives this data back as it was sent, parses it correctly.</p>