Re: Maximum sockets

From: Michael K. O'Neill (mikeathon2000_at_nospam.hotmail.com)
Date: 02/10/05


Date: Thu, 10 Feb 2005 09:14:33 -0800


"Phil Frisbie, Jr." <phil@hawksoft.com> wrote in message
news:eslE5FwDFHA.3368@TK2MSFTNGP10.phx.gbl...
> <snip>
> Yes, you found your problem, even if you did not understand that answer!
When
> you call connect() Windows assigns it to a unused port. The problem is
that by
> default Windows only uses the ports from 1024 through 5000. When you close
a TCP
> socket, it stays in the CLOSE_WAIT for about two minutes, so you can only
> connect and close less than 3976 sockets every two minutes.
>
> --
> Phil Frisbie, Jr.
> Hawk Software
> http://www.hawksoft.com
>

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".

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.

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?

Mike



Relevant Pages

  • Re: Problems with SO_REUSEADDR
    ... did you bind both sockets to a specific ip address _and_ port? ... the same port # was used. ... Phil Frisbie, Jr. ...
    (microsoft.public.win32.programmer.networks)
  • Re: network programming: how does s.accept() work?
    ... The program you contact at Google is a server. ... so, the server will usually assign a new port, say 56399, specifically ... connections to a server remain on the same port, ... sockets is what identifies them. ...
    (comp.lang.python)
  • Re: Listening and Establish TCP connections on/from the same IP end po
    ... and accept client connections as well as be able to establish connections to ... The application needs to listen on a specific port because that's where the ... But it does not allow both sockets to actually _use_ that IP/port at the same time, nor would there be any reliable way to let that happen. ... Client ports are pretty much _never_ assigned according to protocol, and firewalls don't block inbound traffic based on the sender's port at all. ...
    (microsoft.public.dotnet.framework)
  • Re: security risk of having a long list of services in inetd
    ... for connections on certain internet sockets. ... the string 'ssh' means TCP port 22. ... But if there's no program sitting there listening on the port there's ...
    (Debian-User)
  • Re: Socket switch delay
    ... hadn't realized the bit about the completion port... ... > can come back with partial buffers from a completion io. ... > in the client and server. ... > remember changing in the server was the "non-blocking sockets" together ...
    (microsoft.public.win32.programmer.networks)