Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to run multple port node

var http=require('http');
var url = require('url');
var ports = [7006, 7007, 7008, 7009];
var servers = [];
var s;
function reqHandler(req, res) {
        var serPort=req.headers.host.split(":");
        console.log("PORT:"+serPort[1]);//here i get it using http header.
}
ports.forEach(function(port) {
    s = http.createServer(reqHandler);
    s.listen(port);
    servers.push(s);
});
Comment

how to run multple port node

var http=require('http');
var ports = [7006, 7007, 7008, 7009];
var servers = [];
var s;
function reqHandler(req, res) {
    console.log({
        remoteAddress: req.socket.remoteAddress,
        remotePort: req.socket.remotePort,
        localAddress: req.socket.localAddress,
        localPort: req.socket.localPort,
    });
}
ports.forEach(function(port) {
    s = http.createServer(reqHandler);
    s.listen(port);
    servers.push(s);
});
Comment

how to run multple port node

var express = require('express');

let app1 = express();
let app2 = express();

app1.listen(3000, () => {
  console.log("Started server on 3000");
});

app2.listen(3002, () => {
  console.log("Started server on 3002");   
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: tableau js api 
Javascript :: when chrome loads data it resets scroll 
Javascript :: js find place value 
Javascript :: react generate ethereum address 
Javascript :: query sequnce graphql 
Javascript :: copy two fields to one javascript 
Javascript :: which node primary pacemaker of heart 
Javascript :: keyboard is underlined in eclipse javascript 
Javascript :: what does js stand for 
Javascript :: console log update status bar 
Javascript :: add edit delete from table using jquery 
Javascript :: react hooks simple projects 
Javascript :: what is @ atsign in first of file path nodejs 
Javascript :: youtube movie trailer angular 
Javascript :: jquery how to detect click outside off-canvas-navigation 
Javascript :: calculate string value in javascript 
Javascript :: react router not working with aws amplify 
Javascript :: what is event in function inside prantesisi 
Javascript :: javascript object property + multilevel + optional chaining 
Javascript :: fabric js background pathern 
Javascript :: Error: node_modules/@angular/fire/database/interfaces.d.ts:2:10 
Javascript :: how to check if an object from database is undefined in javascript 
Javascript :: JavaScript Operator Precedence Values 
Javascript :: rust zola vuejs 
Javascript :: erb object to json 
Javascript :: use variable in function returned by another function 
Javascript :: jsdelivr discord 
Javascript :: javascript mvc patetern 
Javascript :: how to open same project on different devices vue js 
Javascript :: add component to route 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =