Re: help needed getting unique integer associated with socket
apm35@student.open.ac.uk wrote:
Two distinct clients cannot be connected with the same
file descriptor at the same time. I am hoping the same applies in the
java version when I make it use IP address and port number instead of
file descriptor.
For scenarios when you can count on getting the real client port, the key
phrase "at the same time" should help you. As long as a client holds a
connection, it'll be on the same port.
I've just never trusted a black-box extrinsic process like a client acquiring
its port to be a source of unique identifiers. There is nothing in that
process that makes such a promise. Even the file descriptor approach could be
broken if ported to an operating system that worked with some unconventional
notion of file I/O. (Not that I know of any such, but why limit the world to
my knowledge or imagination?)
Lew said:
Also, some security software could mask the client port, making every
client behind it seem to come from the same port or from some obfuscated port
not correlated to the actual client.
apm35:
Gulp. Well thank goodness this cannot apply in this particular case.
But this is useful to know, thanks! I wonder where I can find out more
that, just out of curiosity..
I do not know of specific cases. I do know that security software like
WebSeal, or really any proxy, makes connections on behalf of the client node.
So the connection the server sees is from the proxy, not the "real" client.
This is unlikely to be an issue in your case because you don't have a proxy
and you are holding connections, not reconnecting for each request.
If you control the network(s) involved and all the firewalls you can
compensate for these phenomena.
Indeed, and luckily, I can.
Then your approach will likely work.
Very often a solution works in a particular case that has dangers in the
general. As long as no one tries to expand the IP:port scheme into the wide
area network, you should be all right. The trick is knowing what techniques
scale across the firewalls and proxies.
--
Lew