News  [SoftwareSite

Latest News
Older News
RSS Feed
 
Complete Projects
Useful Classes
Top Downloads
Message Board
AllAPI.net
 
Send Comments
Software License
Mentalis.org Buttons
Donate
 
Forums -> Security Library Forum
 
SecureTcpClient Inherit TcpClient?  
by cooperd [cooperd at umich dot edu]
posted on 2004/12/23

This may be a naive question, but is there a reason Org.Mentalis.Security.Ssl.SecureTcpClient doesn't inherit from System.Net.Sockets.TcpClient? I only ask because it would be convenient to use the SecureTcpClient connection wherever a regular TcpClient connection could be used - possibly through typecasting.

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].

 

Copyright © 2002-2007, The Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.