我有两个文件,一个是server.js,另一个是server2.js。 两者都有运行在具有不同端口的服务器实例。
Server.js代码:***
var http = require("http");
http.createServer(function (req, res) {
console.log("server running at 8080");
res.writeHead(200);
res.write("hello from server running at 8080");
res.end();
}).listen(8080);
Server2.js:***
var http = require("http");
http.createServer(function (req, res) {
console.log("server running at 8080");
res.writeHead(200);
res.write("hello from server running at 8084");
res.end();
}).listen(8084);