For anyone unfamiliar with the topic, see my short article "What are
Sockets?":
http://nebula-rnd.com/articles/sockets.htm
That will also help to understand my response below.

Original text snipped to a minimum.

Gyle Iverson wrote:
> Unfortunately, the initServerSocket() function has a few
> flaws that stopped this project.  

> 1) The initServerSocket() function precludes using the
> standard socket behavior of letting the socket sub-system
> assign any available port number when the port number 0
> is specified. The initServerSocket() function translates
> all port numbers less than 1 to port 40001.

I've never seen a socket server use a random port.  Clients never use a
pre-determined port.  Clients need to know the port of a server, so a
server absolutely requires a fixed and well-known port.  Why do you need an
assigned port for a server?

> 2) The other issue with the initServerSocket() is that it
> does not recognize when another process already has a
> given port open for listening.

I haven't read the specs for initServerSocket but if it doesn't return a
non-zero for an attachment failure then yes, it's probably broken.

However, in general, a given service should only have one listening
process.  It is valid to have a range of ports which all respond to inbound
connections as a single service - that is, multiple servers will be
listening to different socket ports, even if they support the same
application/transport service.  Coordination of what ports are in use for a
given service should be done by the application, so you should never really
get to a failure in initServerSocket.  If nothing else you can use netstat
to see what ports are in use and use a recognized port that is unallocated.
Again, if you randomly generate a socket port for a service, how will any
client know what port to connect to?

Good luck.
Tony Gravagno
Nebula Research and Development
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to