title: How to identify and authenticate different TCP clients (with dynamic IPs) in a Node.js TCP server framework?
body: <p>I have Node.js TCP server framework which acts as a central TCP server connecting to many TCP clients which are sensors gathering and sending data. This is essentially a machine-to-machine communication where the TCP client establishes a connection and starts sending data. The server has to authenticate and then process the data. </p>
  
  <p><strong>What I want to do? --->
  Authenticate each client by identifying them and making sure they are in the users list in the database.</strong></p>
  
  <ol>
  <li><p>I can identify each incoming client by its ip and port. However, each client has a dynamic IP. This means that I cannot rely on it to compare against a list in my DB.</p></li>
  <li><p><strong>My goal here is to make sure that each connection is valid and is part of my user database.</strong> I was thinking along the lines of implementing an 'application layer' where both the sensor(client) and the TCP server know a string which they match. When the client setups a connection, it sends this string and this is used by the server to compare against a list in the database.  This way the client emits a 'keyword' each time it establishes a connection. </p></li>
  </ol>
  
  <p>If this is a viable method, how can I use the node.js 'NET' module to emit a keyword only when the connection is established? I don't see any such provision. </p>
  
  <p>Also, is there a better way to identify clients in a M-M connections? Any pointers will be helpful. </p>