Re: CSocket::Create() - port allocation
- From: "Michael K. O'Neill" <MikeAThon2000@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 20 Oct 2006 12:12:25 -0700
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 systemsallocate ephemeral
ports in the new range.wrote:
joe
On Fri, 20 Oct 2006 03:05:02 -0700, len <len@xxxxxxxxxxxxxxxxxxxxxxxxx>
CSocket::Create()
Hi there.
I'm using Visual C++ 6 and have an application that uses
portto allocate a TCP/IP listening port - with a value of 0 passed in as the
Isnumber so that MFC will take care of the allocation.
When I do this, I find that the ports allocated range from 1024 upwards.
65535 inthis correct? Shouldn't the ports allocated range from 49152 through
order to avoid the Registered Ports?Joseph M. Newcomer [MVP]
Any info would be appreciated!
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: CSocket::Create() - port allocation
- From: AliR \(VC++ MVP\)
- Re: CSocket::Create() - port allocation
- References:
- Re: CSocket::Create() - port allocation
- From: Joseph M . Newcomer
- Re: CSocket::Create() - port allocation
- Prev by Date: Re: echo server changes the incoming package's port number
- Next by Date: Re: Embedding Simple MFC GUI app into website
- Previous by thread: Re: CSocket::Create() - port allocation
- Next by thread: Re: CSocket::Create() - port allocation
- Index(es):
Relevant Pages
|