node.js - Socket io Client Side connection Failure -
i trying write simple code client server communication,my server starting when start client throws error,i have posted code below please solve this.
server.js
 express = require('express');       var app = express();       var server = require('http').createserver(app);       var io = require('socket.io')(server);     io.set('transports', ['xhr-polling']);      app.use(express.static(__dirname + '/bower_components'));       app.get('/', function(req, res,next) {           res.sendfile(__dirname + '/index.html');     });      io.on('connection', function(client) {           console.log('client connected...');          client.on('join', function(data) {             console.log(data);         });      });      server.listen(8080,function() {     console.log("server conected"); });     index.html
<!doctype html>   <html lang="en">       <head>         <script src="server/node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script>          <script>               var socket = io.connect('http://localhost:8080',{                   'sync disconnect on unload': true                 });             socket.on('connect', function(data) {                 socket.emit('join', 'hello world client');             });         </script>     </head>     <body>         <h1>hello world!</h1>         <div id="future"></div>         <form id="form" id="chat_form">             <input id="chat_input" type="text">             <input type="submit" value="send">         </form>                             </body> </html>     
 
 
  
Comments
Post a Comment