Re: CSocket::Create() - port allocation

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Ephemeral ports are assigned by the winsock stack, which is entirely
unrelated to the IDE (VS6 or otherwise) that you happen to be programming
in.

The ephemeral port range is a registry-controlled value, and is configurable
using the MaxUserPorts registry parameter. The default value is 5000. Thus,
by default, when an application requests any socket from the system to use
for an outbound call, a port between the values of 1024 and 5000 is
supplied. The MaxUserPorts parameter can be used to set the value of the
uppermost port. See
http://www.microsoft.com/technet/itsolutions/network/deploy/depovg/tcpip2k.mspx

The precise location of MaxUserPorts is
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

However, in answer to the original question, it's wrong to establish a
*listening* port at an ephemeral number. You should select a port that you
want your service to listen at, and then bind to that port. If you use an
ephemeral port number, then the port will change from run-to-run, and then
how would anyone ever find your service?

Incidentally, the registered port range is 1-1024. Why do you think it
extends up to 49152?

Mike


"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:rh4ij2dcb37rcltj9c5kdh6osios4cg99q@xxxxxxxxxx
The change in the ephemeral port allocation postdates the release of VS6.
Therefore,
older systems allocate ephemeral ports in the low range; newer systems
allocate ephemeral
ports in the new range.
joe

On Fri, 20 Oct 2006 03:05:02 -0700, len <len@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

Hi there.

I'm using Visual C++ 6 and have an application that uses
CSocket::Create()
to allocate a TCP/IP listening port - with a value of 0 passed in as the
port
number so that MFC will take care of the allocation.

When I do this, I find that the ports allocated range from 1024 upwards.
Is
this correct? Shouldn't the ports allocated range from 49152 through
65535 in
order to avoid the Registered Ports?

Any info would be appreciated!
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


.



Relevant Pages

  • Re: Timeout error when using FTP from Windows DOS prompt
    ... > While trying to get multiple files from an IIS FTP site using the standard ... address and a port. ... The ephemeral port range in Windows' TCP is 1024-5000. ... client (it uses a PORT command to indicate this information). ...
    (microsoft.public.inetserver.iis.ftp)
  • Localhost packets on WAN
    ... to an ephemeral port on one of our WAN IPs. ... about 10 minutes apart for each packet in the pair. ... Internet Protocol, Src Addr: 127.0.0.1, Dst Addr: WAN_IP ...
    (Incidents)
  • Re: How to close the unnecessary Ports
    ... types of port ranges on your ... TCP/IPv4 connection consists of two endpoints, ... Therefore, when a client ... terminates, the ephemeral port is available for reuse, although most IP ...
    (alt.computer.security)
  • RE: Multiple FTP Problems
    ... Subject: Multiple FTP Problems ... of the thought about "not enough TCP ports" available. ... You define the ephemeral port range in TCPIP's profile ... Each transfer of a file needs a new port. ...
    (bit.listserv.ibm-main)
  • Re: Serial Port Application
    ... Can the registry be viewed from a Windows CE image? ... drivers which are actually active. ... >> Although the serial com port I use is defined under. ... I have created a new serial test program ...
    (microsoft.public.windowsce.app.development)