1var http=require('http');
2var url = require('url');
3var ports = [7006, 7007, 7008, 7009];
4var servers = [];
5var s;
6function reqHandler(req, res) {
7 var serPort=req.headers.host.split(":");
8 console.log("PORT:"+serPort[1]);//here i get it using http header.
9}
10ports.forEach(function(port) {
11 s = http.createServer(reqHandler);
12 s.listen(port);
13 servers.push(s);
14});
1var http=require('http');
2var ports = [7006, 7007, 7008, 7009];
3var servers = [];
4var s;
5function reqHandler(req, res) {
6 console.log({
7 remoteAddress: req.socket.remoteAddress,
8 remotePort: req.socket.remotePort,
9 localAddress: req.socket.localAddress,
10 localPort: req.socket.localPort,
11 });
12}
13ports.forEach(function(port) {
14 s = http.createServer(reqHandler);
15 s.listen(port);
16 servers.push(s);
17});
1var express = require('express');
2
3let app1 = express();
4let app2 = express();
5
6app1.listen(3000, () => {
7 console.log("Started server on 3000");
8});
9
10app2.listen(3002, () => {
11 console.log("Started server on 3002");
12});