title: run a javascript program without terminating inside node.js
body: <p>I want to run a javascript program without terminating inside node.js :---</p>
  
  <p>Is it the right way to do it by <code>using while(1);</code> ?</p>
  
  <p>Inside this javascript program i have created a websocket &amp; listing to it.<br>
  Whenever data comes on websocket it throws on console.log.</p>
  
  <p>test.js :--</p>
  
  <pre><code>var tt = new websocket_fun();
  
  function websocket_fun()
  {
  
     var temp = new websocket_create();
  
     while(1);
  }
  function websocket_create()  
  {
  
       // Open the socket
      this.socket = new WebSocket( "192.168.0.11:8080"); 
      // Bind events
      this.socket.onmessage = this.onMessagesocket.bind(this);
      this.socket.onopen = this.onOpensocket.bind(this);
      this.socket.onclose = this.onClosesocket.bind(this);
  
  
  }
  
  websocket_create.prototype.onMessagesocket = function(msg)
  {
    console.log(msg);
  }
  
  websocket_create.prototype.onOpensocket = function(msg)
  {
    console.log('Open websocket');
  }
  
  websocket_create.prototype.onClosesocket = function(msg)
  {
    console.log('Close websocket');
  }
  </code></pre>
  
  <p>run :---<br>
  node test.js</p>