Re: hashCode() for Custom classes
Logan Shaw wrote:
[1] Yes, it's true that the only thing that absolutely has to be
unique is the combination of source IP, source port, dest IP,
and dest port (and time), but in practice AFAIK TCP
implementations tend to just pick a new ephemeral port number
Nope. :)
Certain severs/NAT servers that follow a convention (I'd blame Microsoft
but this one really isn't their fault) that re-uses port numbers. In
other words, if you open a connection, then close it again, the standard
guarantees that the next port used will be the same as the last one.
You'll keep getting the same IP address and port number over and over.
That might or might not affect your hashing, depending on what you do
with your connection objects after the connection closes. (Get rid of
them really really quickly, I hope.)
Of course, with multiple connections in succession from the same
user-name and password, including those in the hash won't help, because
everything will still be the same, even though the connections are
different.
(BSD based servers do not use this convention, because it's a really
stupid security hole.)