O
Oren Shomron
Hello,
I came across an annoying bug in the Socket class.
Apparently its GetHashCode() implementation returns
its Handle property value.
Since calling Close() sets the Handle to -1, GetHashCode()
returns -1 as well.
This has the effect of socket objects *changing identity* on me.
See the following example:
// Add a socket as the key in my hashtable:
Hashtable hash = new Hashtable();
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
hash.Add(sock, new Integer(2));
// Close the socket
sock.Close();
// Fails! hash.Count is still 1!!!!!
hash.Remove(sock);
--------------------------------------------
This is obviously a bug.
Does anyone know how to get this behavior changed for the next
Framework release?
Thanks,
- Oren Shomron
I came across an annoying bug in the Socket class.
Apparently its GetHashCode() implementation returns
its Handle property value.
Since calling Close() sets the Handle to -1, GetHashCode()
returns -1 as well.
This has the effect of socket objects *changing identity* on me.
See the following example:
// Add a socket as the key in my hashtable:
Hashtable hash = new Hashtable();
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
hash.Add(sock, new Integer(2));
// Close the socket
sock.Close();
// Fails! hash.Count is still 1!!!!!
hash.Remove(sock);
--------------------------------------------
This is obviously a bug.
Does anyone know how to get this behavior changed for the next
Framework release?
Thanks,
- Oren Shomron