public virtual void Close(object clientData) { Stream stream = clientData as Stream; if (stream == null) throw new ArgumentException("Can't get underlying stream to close"); stream.Close(); }