title: Socket.io on port 8888 and webserver on port 80 - can't combine the two
body: <p>I have the following node.js server-side code:</p>
  
  <pre><code>var app = require('http').createServer(handler)
    , io = require('socket.io').listen(app)
    , fs = require('fs')
  
  app.listen(8888);
  
  var fn='/home/eamorr/workspace/node_proxy_remote5/data';
  
  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) {
      fs.watchFile(fn,function(curr,prev){
          //curr.time
          fs.readFile(fn,function(err,data){
              socket.emit('data',data.toString());
              console.log(data);
          });
      });
  });
  </code></pre>
  
  <p>As you can see, I'm watching a file and sending modifications to the browser.</p>
  
  <p>On the client side, I have:</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
  &lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript" src="./jqPlot/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="./jqPlot/jquery.jqplot.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="./jqPlot/plugins/jqplot.canvasTextRenderer.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="./jqPlot/plugins/jqplot.canvasAxisLabelRenderer.min.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" type="text/css" href="./jqPlot/jquery.jqplot.min.css" /&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
  var socket = io.connect('http://localhost:8888');
  socket.on('data', function (data) {
      console.log(data);
      //socket.emit('my other event', { my: 'data' });
  });
  &lt;/script&gt;
  &lt;div id="chart2" style="height:300px; width:500px;"&gt;&lt;/div&gt;
  
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
      var plot2 = $.jqplot ('chart2', [[3,7,9,1,5,3,8,2,5]], {
          // Give the plot a title.
          title: 'Bandwidth over port 10001',
          // You can specify options for all axes on the plot at once with
          // the axesDefaults object.  Here, we're using a canvas renderer
          // to draw the axis label which allows rotated text.
          axesDefaults: {
            labelRenderer: $.jqplot.CanvasAxisLabelRenderer
          },
          // Likewise, seriesDefaults specifies default options for all
          // series in a plot.  Options specified in seriesDefaults or
          // axesDefaults can be overridden by individual series or
          // axes options.
          // Here we turn on smoothing for the line.
          seriesDefaults: {
              rendererOptions: {
                  smooth: true
              }
          },
          // An axes object holds options for all axes.
          // Allowable axes are xaxis, x2axis, yaxis, y2axis, y3axis, ...
          // Up to 9 y axes are supported.
          axes: {
            // options for each axis are specified in seperate option objects.
            xaxis: {
              label: "X Axis",
              // Turn off "padding".  This will allow data point to lie on the
              // edges of the grid.  Default padding is 1.2 and will keep all
              // points inside the bounds of the grid.
              pad: 0
            },
            yaxis: {
              label: "Y Axis"
            }
          }
      });
  });
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>As you can see, I'm trying to draw a graph using jqPlot with the data sent from the server.</p>
  
  <p>The problem I have with this code is that if I navigate to <a href="http://localhost:80" rel="nofollow">http://localhost:80</a>, the graph shows up fine, but no websockets are initiated. If I navigate to <a href="http://localhost:8888" rel="nofollow">http://localhost:8888</a>, the graph won't show up, but the websocket work fine! How can I combine both node.js and jQuery?</p>
  
  <p>Many thanks in advance,</p>