title: TypeError: sockets.forEach is not a function
body: <p>i am trying to create a simple personal chat with node js and android.the following code works fine</p>
  
  <pre><code>socket.on('message' , function (msg) {
      console.log(msg);
     io.emit('message' , {message : msg});
  })
  </code></pre>
  
  <p>when a message is receive from a client, the server send it to all other client connected to the server. but the problem is that the sender receive his own message as well. to overcome this issue i am using the following code</p>
  
  <pre><code> socket.on('message' , function (msg) {
      console.log(msg);
      //io.emit('message' , {message : msg});
     var sockets = io.sockets.sockets;
      sockets.forEach(function (sock) {
          if(sock.id != socket.id){
              sock.emit('message' , {message:msg})
          }
      })
  })
  </code></pre>
  
  <p>but the code above produces an error </p>
  
  <blockquote>
    <p>TypeError: sockets.forEach is not a function</p>
  </blockquote>
  
  <p>can anyone help me with this and save my day? thanks in advance. </p>