I would like to override a method in an object that\'s handed to me by a factory that I have little control over.
My specific problem is that I want to override the
You can't replace methods in existing objects - you can't change an existing object's type, for one thing.
You could create a new instance of another class which delegated to the existing instance, but that has limitations too.
In your real world case is there no way you can simply make a separate call to wrap the streams returned by the socket? Can you give more details.