title: How do I point to my node.js server within my PHP app?
body: <p>I have a PHP application, to which I am adding real time capabilities using node.js and socket.io</p>
  
  <p>While I am experienced with PHP Node.js and am finding myself going round in circles.</p>
  
  <p>I have installed both node.js and socket.io.  I have created an a <code>/usr/local/lib/app.js</code> containing the following example code from the socket.io site:</p>
  
  <pre><code>var app = require('http').createServer(handler)
    , io = require('socket.io').listen(app)
    , fs = require('fs')
  
  app.listen(3000);
  
  function handler (req, res) {
    fs.readFile(__dirname + '/index.html',
    function (err, data) {
      if (err) {
        res.writeHead(500);
        return res.end('Error loading index.html');
      }
  
      res.writeHead(200);
      res.end(data);
    });
  }
  
  io.sockets.on('connection', function (socket) {
    socket.emit('news', { hello: 'world' });
    socket.on('my other event', function (data) {
      console.log(data);
    });
  });
  </code></pre>
  
  <p>When I run node <code>/usr/local/lib/app.js</code> I get  <code>info  - socket.io started</code> So everything so far appears to work correctly.</p>
  
  <p>However the next step is to add a script for the client to connect to the socket.io server upon load.</p>
  
  <p>Within my PHP app I am adding the following:</p>
  
  <pre><code>&lt;script src="http://xx.xx.xx.xx:3000/socket.io/socket.io.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          var socket = io.connect('http://localhost');
          socket.on('news', function (data) {
              console.log(data);
              socket.emit('my other event', { my: 'data' });
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>With my sites ip address in places of the xx's.  However the request for the socket.io.js file always simply returns a 404 error.</p>
  
  <p>I am clearly not grasping something.  Hopefully someone can help.</p>