Re: Maximum sockets
From: Phil Frisbie, Jr. (phil_at_hawksoft.com)
Date: 02/10/05
- Next message: Jorge Marcos: "RE: avoid dns scavenging"
- Previous message: RD: "RE: avoid dns scavenging"
- In reply to: Michael K. O'Neill: "Re: Maximum sockets"
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Jorge Marcos: "RE: avoid dns scavenging"
- Previous message: RD: "RE: avoid dns scavenging"
- In reply to: Michael K. O'Neill: "Re: Maximum sockets"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|