by Pieter Philippaerts [Pieter at mentalis dot org] posted on 2004/12/25 |
|
Our main problem was that we couldn't inherit from the Socket class. The Send and Receive methods of the Socket class are not marked as 'virtual', so inheriting our SecureSocket from Socket would be asking for problems. Code like this:
Socket s = new SecureSocket(...);
s.Send(...);
would completely bypass our code, because of the non-virtual Send method. As a result, we created the VirtualSocket and inherited our SecureSocket from that class.
We then implemented the SecureNetworkStream, from which we were also unable to inherit due to the fact that all its constructors are expecting Socket objects and we weren't inheriting from Sockets.
Finally, we had to rewrite the TcpClient class too, because it insists on creating an internal socket and because we would have had problems with overriding the GetStream method [it returns a NetworkStream -- not a Stream]. |