title: How to send message to individual client in node.js using only Net module(not socket.io)
body: <p>Simple code:</p>
  
  <pre><code>process.stdin.resume()
  process.stdin.setEncoding('utf8');
  var server = createServer();
  server.listen(9999);
  server.on('connection',function(sock){
      console.log('CONNECTED:'+sock.remoteAddress+":"+sock.remotePort);
      process.stdin.on('data',function(send){
              sock.write(send);
      });
  }
  </code></pre>
  
  <ul>
  <li><p>When receiving connection from 10.10.10.1 and 10.10.10.2,
  message "CONNECTED:10.10.10.1:xxx" and "CONNECTED:10.10.10.2:xxx"
  are display on terminal</p></li>
  <li><p>To send message to a client, I used sock.write(send)..
  but, All clients received message</p></li>
  <li>How can I send a message to a specific client.
  From googling there are many socket.io related documents(solutions)..
  but, before using socket.io, I want to know node.js itself.
  (or javascript itself?) </li>
  </ul>
  
  <hr>
  
  <ul>
  <li><p>After reading Vadim's comment, I wrote down more code below.
  fully working code.  </p></li>
  <li><p>I add two things. According to Vadim's comment, add property sock.id
  and using property sock.remoteAddress, send server's stdin message to<br>
  10.10.10.1 client only</p></li>
  </ul>
  
  <p><pre><code></p>
  
  var net = require('net')
  process.stdin.resume()
  process.stdin.setEncoding('utf8');
  var server = net.createServer();
  server.listen(9999);
  server.on('connection',function(sock){
          sock.write('input your ID: ',function(){
                  var setsockid = function(data){
                          id=data.toString().replace('\r\n','');
                          console.log('ID:'+id+' added!!')
                          sock.id=id
                          sock.removeListener('data',setsockid);
                  };
                  sock.on('data',setsockid);
                  sock.on('data',function(data){
                          d=data.toString().replace('\r\n','');
                          console.log(sock.id+' say: '+d);
                  });
          });
      console.log('CONNECTED:'+sock.remoteAddress+":"+sock.remotePort);
      process.stdin.on('data',function(send){
              if (sock.remoteAddress=='10.10.10.1') sock.write(send);
      });
  });
  </code></pre>