how to dynamically allocate and advertise port numbers by name

  • Thread starter Thread starter B or T
  • Start date Start date
B

B or T

How do you dynamically allocate a port number (assured that it is not
already in use), and advertise it (by name or ID)?

Every book I come across seems to hard code/configure a specific port
number. This obviously won't work in general, if different applications try
to grab the same ports, or if multiple instances of the application are
running on the same machine (such as two instances of a client program
requiring callback connections).

On other platforms this is done by a "port broker". Is there a standard
port brokers in .net (or accessible to .net) for dynamically allocated port
numbers? Would system.directoryServices be the place to look?
 
Hi,

B or T said:
How do you dynamically allocate a port number (assured that it is not
already in use), and advertise it (by name or ID)?

Every book I come across seems to hard code/configure a specific port
number. This obviously won't work in general, if different applications try
to grab the same ports, or if multiple instances of the application are
running on the same machine (such as two instances of a client program
requiring callback connections).

For most applications/protocols this is the way things work. (ie. protocols
HTTP/POP3/IMAP/FTP/SSH and applications MSN messenger/games/remote desktop)
On other platforms this is done by a "port broker". Is there a standard
port brokers in .net (or accessible to .net) for dynamically allocated port
numbers? Would system.directoryServices be the place to look?

It can indeed give problems but I am not aware of any port brokers in the
Base Class Library.

Herman Eldering
 
Back
Top