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 7814747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:17:33+00:00 2026-06-02T05:17:33+00:00

I’m working on a server application and I want to open a lot of

  • 0

I’m working on a server application and I want to open a lot of ports. What is the maximum number of ports I can open and a windows machine? Thanks!

EDIT: What I mean is how many ports can I open for listening (as a server)

  • 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-06-02T05:17:35+00:00Added an answer on June 2, 2026 at 5:17 am

    What most people aren’t explaining to you barring the one comment by tsells is that most likely you have an invalid assumption of how tcp stacks typically work (This was actually something I got confused with until not too long ago).

    The reason is that when you have a TcpListener (Specific to DotNet but probably applicable to most other tcp libraries) is that when you begin listening and an incoming connection takes place the stack will listen on a port of your choosing (eg: Port: 1234) but once connected will move the connection to a (typically) random unassigned port.

    So for example looking at the following code.

      // Set the TcpListener on port 13000.
      Int32 port = 13000;
      IPAddress localAddr = IPAddress.Parse("127.0.0.1");
    
      // TcpListener server = new TcpListener(port);
      server = new TcpListener(localAddr, port);
    
      // Start listening for client requests.
      server.Start();
    
      // Buffer for reading data
      Byte[] bytes = new Byte[256];
      String data = null;
    
      // Enter the listening loop.
      while(true) 
      {
        Console.Write("Waiting for a connection... ");
    
        // Perform a blocking call to accept requests.
        // You could also user server.AcceptSocket() here.
        TcpClient client = server.AcceptTcpClient();            
        Console.WriteLine("Connected!");
        //Here you will find that if you look at the client LocalEndPoint a random dynamic port will be assigned.
      }
    

    What this basically means is that unless you’ve got a VERY GOOD reason you shouldn’t really care about these implementational details and the maximum open ports is fundamentally irrelevant (Also good luck trying to write something that spawns 30000 threads and maintains those connections correctly and efficiently).

    PS: I have also verified inside of the System.Net.Sockets.TcpListener when a port number is provided the following code is called and will throw a ArgumentOutOfRangeException if it fails this test. This confirms what ‘Igby Largeman’ said in that it is a 16 bit unsigned integer.

    public static bool ValidateTcpPort(int port) 
    {
        if (port >= 0)
        {
            return port <= 0xffff;  //65535
        }
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
Does anyone know how can I replace this 2 symbol below from the string
I want to construct a data frame in an Rcpp function, but when I

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.