Re: Maximum sockets

From: Phil Frisbie, Jr. (phil_at_hawksoft.com)
Date: 02/10/05


Date: Thu, 10 Feb 2005 09:55:26 -0800

Michael K. O'Neill wrote:

> I thought the WSAEADDRINUSE error occurred only when a connection was
> attempted on the same four-tuple (i.e., on the exact same IP and port for
> both the client and server). If that's correct, then it's not entirely
> accurate to say "you can only connect and close less than 3976 sockets every
> two minutes." It would be more accurate to say "you can only connect and
> close less than 3976 sockets every two minutes between the same two
> machines".

Yes, I stand corrected.

> This MSDN KB article talks about the issue, although in the context of a
> very specific problem: "PRB: "WSAEADDRESSINUSE" Error Message When You Try
> to Connect Through an Anonymous Port After You Increase the IMAP Connection
> Limit" at http://support.microsoft.com/default.aspx?scid=kb;en-us;319502 .
> I had seen this article before, but it was hard to find it again since
> someone had misspelled WSAEADDRINUSE (it's not "WSAEADDRESSINUSE" as spelled
> in the article).
>
> Incidentally, I think that "ephemeral port" is often called "anonymous port"
> in Winsock-world.

Maybe, but I do not remember seeing it called that. Say, I just Googled the news
groups and found exactly three messages that used the phrase 'anonymous port',
and over seven HUNDRED that used 'ephemeral port'.

> In any event, in a nutshell, could you explain how your library overcomes
> the "1024 to 5000" port range limitation without a registry edit? Do you
> close the socket with SO_REUSEADDR, or maybe assign port numbers yourself?

I assign the port numbers myself with my own wrapper for bind(). Basically, I
cycle through all ports from 1024 through 65535. If bind() fails I try the next
port, but I only try a preset number of ports before I return failure to avoid a
long wait if all ports are still in use.

> Mike

-- 
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com


Relevant Pages

  • Re: How to listen to more a specific IP and specific ports
    ... bind my socket to specific unlimited and selective IP addresses. ... Moreover, in Unix/Linux Berekly network programming, you can determin the ... port numbers. ...
    (microsoft.public.win32.programmer.networks)
  • Re: How to listen to more a specific IP and specific ports
    ... I have read this long time ago in the textbook Unix Network Programming ... service and connect our socket to INADDR_ANY and then listen for incoming ... Its clear to me on how to bind with ... port numbers. ...
    (microsoft.public.win32.programmer.networks)
  • Re: How to listen to more a specific IP and specific ports
    ... bind my socket to specific unlimited and selective IP addresses. ... Moreover, in Unix/Linux Berekly network programming, you can determin the IP ... port numbers. ...
    (microsoft.public.win32.programmer.networks)
  • Re: How to listen to more a specific IP and specific ports
    ... bind my socket to specific unlimited and selective IP addresses. ... port numbers. ... is not feasible because the particular IPs are not fixed. ...
    (microsoft.public.win32.programmer.networks)
  • FreeBSD Security Advisory: FreeBSD-SA-01:18.bind
    ... BIND is an implementation of the Domain Name Service protocols. ... assist the ability of attackers to exploit the primary vulnerability ... the bind8 port in the ports collection ... If you have chosen to install BIND from the ports collection and are ...
    (FreeBSD-Security)