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

  • SEARCH
  • Home
  • 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 6134273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:20:05+00:00 2026-05-23T17:20:05+00:00

I am creating a server (desktop based) which listens on a port 4504 using

  • 0

I am creating a server (desktop based) which listens on a port 4504 using this bit of code

                IPAddress[] AddressAr = null;
                String ServerHostName = "";

                try
                {
                    ServerHostName = Dns.GetHostName();
                    IPHostEntry ipEntry = Dns.GetHostByName(ServerHostName);
                    AddressAr = ipEntry.AddressList;
                }
                catch (Exception) { }

                if (AddressAr == null || AddressAr.Length < 1)
                {
                    return "Unable to get local address ... Error";
                }

                Listener_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                Listener_Socket.Bind(new IPEndPoint(AddressAr[0], Port));
                Listener_Socket.Listen(-1);

                Listener_Socket.BeginAccept(new AsyncCallback(EndAccept), Listener_Socket);

                return ("Listening On " + AddressAr[0].ToString() + ":" + Port + "... OK");

Now the problem is that, I want to run this on my server and the value of AddressAr[0] I want to be is the public IP of my server, but this snippet returns the local lan address of the server.

Like I want AddressAr[0] = “180.123.45.6” something [which is the public IP of my server], but with this snippet I am getting AddressAr[0] = “192.168.2.2”

PS: I am running this server as a desktop app and my trials were in the debugging mode.

I’d appreciate any help.
Thank You.

  • 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-23T17:20:05+00:00Added an answer on May 23, 2026 at 5:20 pm

    You need to listen on your local host, which will be your 192.168.2.2 (this is correct) and then forward the external packets/traffic from your public address to your local machine.

    If you’re using, for instance, a linksys router, you can go to NAT/QOS and forward any incoming traffic on a specific port, e.g. 4504 to your local machine address 192.168.2.2

    Any standard home router will have port forwarding built into the firmware.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a networked server for a boggle-clone I wrote in python, which accepts
I am just getting started creating an AJAX application using server side push. I
I'm creating a Rails application which will be deployed to desktop machines, running both
I need a programmatic way of creating a SQL Server ODBC Data Source. I
As an addition to my previous post on Creating a web server in pure
When creating a new build in Team Foundation Server, I get the following error
I'm creating a log shipping configuration between two sql server 2005 instances. I'm shipping
I'm creating an ASP.NET web application to schedule tasks on our server from a
What are the recommendations of software products for creating automated backups of SQL Server
In a stored procedure, when is #Temptable created in SQL Server 2005? When creating

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.