William Stacey said:
Yes, we know the system can assign ephemeral ports using 0 for port number.
But again, we are talking about a server app. So I still have the same
question - why when you can use the connection socket to identify the
client?
And I still have the same response - to have multiple connections which
don't require the same protocol.
? I can't think of a mainstream server that does that besides maybe ftp
server that does something close.
Neither can I. That doesn't mean your generalisation is correct though.
And ftp has firewall issues for this reason.
Indeed - and if a firewall might be involved, it's clearly a bad idea.
However, that's not always the case.
Who says you can't use both udp and tcp on the same port? You can listen on
one port and service as many unique client/port pairs as the system will
allow.
I don't see where UDP comes in here. A single port should only service
a single protocol. What you can do is have two ports, one for one
protocol and one for another, of course. That would be a better answer
to my suggested "problem". However, here's another scenario:
You have an app which you don't want to allocate a fixed port number
for (as fixed port numbers are limited, so there may be clashes).
However, you want to communicate in a simple stream-based fashion, e.g.
with other instances of the same app running on the same box. You could
use some other IPC mechanism to share the port number, but that IPC
mechanism may not be nearly as well suited to the rest of the data
streaming as simple networking (which may already be part of the app
for other reasons). Dynamically creating a port and then sharing the
number creates a simple clash-free stream.
I am not talking about a server with a few ports open for specific
services (i.e. w2k, ad, etc). That is fine and normal. The OP wants a
seperate port on the server for each client that connects AFAICT. All I am
saying is there is no need for that using sockets, unless I miss his point.
And I'm saying that while there *may* not be a need, saying that
dynamically allocated port numbers is *never* needed (or at least
advantageous) is being short-sighted.