Ummm... Reading your email, I guess you don't have exposed /node via localhost
Your socket.io server could be accessed via http://localhost:1337 Try http://localhost:1337/socket.io/socket.io.js and you should get a javascript text Then, alter your HTML from <script src="/node:1337/socket.io/socket.io.js"></script> to <script src="http://localhost:1337/socket.io/socket.io.js"></script> It works? Angel "Java" Lopez @ajlopez On Wed, Sep 25, 2013 at 6:30 PM, Shamir Khandaker <[email protected]>wrote: > I am trying to create a simple chat application using Node js. I am using > a windows operating system. As local server I am using Xampp. I have > installed node. I have also installed socket.io using package.json. The > code in package.json is given below. > > { > "name":"chat", > "version":"0.0.1", > "private":"true", > "dependencies":{ > "socket.io":"0.9.16", > "express":"3.4.0" > } > } > > Then I have written the code for the server. The node server is running in > port 1337. The code for the server is given below. > > var io = require('socket.io').listen(1337); > > io.sockets.on('connection', function (socket) { > socket.emit('news', { hello: 'world' }); > socket.on('my other event', function (data) { > console.log(data); > }); > }); > > Then when I run it, it is running. Then I have written the code for the > client in a index.php file. The code for the client is given below. > > <!DOCTYPE html> > <html> > <head> > <title>Chat app.</title> > </head> > <body> > <script src="// > ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> > <script src="/node:1337/socket.io/socket.io.js"></script> > <script type="text/javascript"> > $(document).ready(function(){ > var socket = io.connect('http: // localhost / node : 1337'); > socket.on('news', function (data) { > console.log(data); > socket.emit('my other event', { my: 'data' }); > }); > }); > </script> > </body> > </html> > > But when I try to the run it with a browser, all I get see in the console > is that access is forbidden. BTW, if it is important all my files including > node_modules is saved in C:\xampp\htdocs\node. Please help me. I am stuck > for quite some days. Thanks in advance. > > -- > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
