global.appRoot = require('app-root-path');
var express = require('express');
var session = require('express-session');
var app = express();
var server1 = app.listen(7788, "0.0.0.0", function() {
console.log('Server listening on port ' + server1.address().port);
});
var server2 = app.listen(5566, "0.0.0.0", function() {
console.log('Server listening on port ' + server2.address().port);
});
var socket = require('socket.io').listen(server1);
var socket2 = require('socket.io').listen(server2);
socket.on('connect', function (socket) {
console.log("hi socket 1");
});
socket2.on('connect', function (socket) {
console.log("hi socket 2");
});
<!doctype html>
<html>
<head>
<script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.1/socket.io.js'></script>
<script>
var socketClient1 = io('ws://localhost:5566');
var socketClient2 = io('ws://localhost:7788');
</script>
</head>
<body>
<ul id='messages'></ul>
</body>
</html>