Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
nodejs
socket.js
socket.js
var sys = require("sys"), http = require("http"), io = require("socket.io"); http.createServer(function(request,response){ sys.puts("The request is received"); response.writeHeader(200, {"Content-Type": "text/html"}); response.write("Hello World"); response.write("<br>And <b>again</b> !"); var delay=3000; setTimeout(function(){ response.write("<br>And again with delay of "+delay+"s"); response.end(); }, delay); }).listen(8080); sys.puts("Server Running on 8080"); //socket message io.listen(http); io.sockets.on('connection', function(socket){ socket.emit('message', {'message': 'helllllo'}); });
Reload page
Preview
W3C validation
Edit Code
JS Console