我是否需要为express(3000)和socket.io指定不同的端口?
错误:端口3000已在使用中
我的代码:
index.js
my @cmd = ("-out", $args->{keyfile}, $args->{keysize});
unshift @cmd, ("-des3", "-passout", "fd:3") if defined $args->{keypass};
# ...
my $h = start ["openssl", "genrsa", @cmd], '<', \$in, '>', \$out, '3<', \$args->{keypass};
的index.html
var express = require('express')
,router = express.Router()
, app = express()
, http = require('http')
, server = http.Server(app)
, io = require('socket.io').listen(server)
server.listen(3000);
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
io.on('connection',function(socket){
console.log("A user is connected");
socket.on('point1', function (value) {
socket.broadcast.emit('point1',value);
});
socket.on('less1', function (value) {
socket.broadcast.emit('less1',value);
});
socket.on('point2', function (value) {
socket.broadcast.emit('point2',value);
});
socket.on('less2', function (value) {
socket.broadcast.emit('less2',value);
});
});
module.exports = router;
或如何在io.connect上传递变量(“use-host:use-port”);