Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:42:54+00:00 2026-05-25T20:42:54+00:00

I have 3 simple NodeJS servers usign NET, HTTP and UDP. Each server listens

  • 0

I have 3 simple NodeJS servers usign NET, HTTP and UDP. Each server listens on port X but has multiple IP addresses. I would like to retrive the actual IP address of the server when the client connects to the server (the IP to where the client connected, the IP that client had to write to connect to the server).

var httpService = http.createServer(function(req, res){
   req.getActualServerAddress();
});
httpService.listen(8000);

var netService = net.createServer(function(socket) {
   socket.getActualServerAddress();
});
netService.listen(8001);

var udpService = dgram.createSocket("udp4");
udpService.on("message", function (msg, rinfo){
   rinfo.getActualServerAddress();
});
udpService.bind(8002);

Thx.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:42:55+00:00Added an answer on May 25, 2026 at 8:42 pm

    If you do not specify the hostname, the server will start at 0.0.0.0. So you may not get your desired outcome[ read Maqurading]. For HTTP you can use the HTTP “Host” header [mandatory since HTTP/1.1] which might be fruitful for your case.

    Still you may give a try with:

    socket.address()
    

    Returns the bound address and port of the socket as reported by the
    operating system. Returns an object with two properties, e.g.
    {“address”:”192.168.57.1″, “port”:62053}

    Here is a sample for tcp:

    var netService = require('net').createServer(function(socket) {
     address = netService.address();
     console.log("Stream on %j", socket.address());
     console.log("opened server on %j", address);
    });
    netService.listen(8001);
    

    Sample for http:

    var httpService = require('http').createServer(function(req, res){
    console.log("Stream on %j", req.connection.address());
        res.end("Hi");
    });
    httpService.listen(8000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I use the http module of nodejs to make a simple http server,
I have a need for a simple, lightweight .Net-based web server engine that will
Writing an HTTP simple server on top of Net node.js module, not using HTTP
I have the following simple http server using Node.js: var http = require('http'); var
I am looking to leverage my existing (and quite simple) NodeJS+SocketIO server application with
Okay, I have a simple test server set up using socket.io in node.js. My
I've got a fairly simple NodeJS app that is nothing but a shell that
I've installed nodejs and ran couple of simple examples like opening a server on
I have a simple weighted tree with a root, nodes and leafs. Now I
I have simple regex \.*\ for me its says select everything between and ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.