On Mon, 11 Aug 2008 15:47:46 -0700, Fernando <Fa************@hotmail.com>
wrote:
Why does the NetworkStream class exist at all if you can read/write
through
a Socket instance ? What is the advantage ?there must be one, i just
didnt
grasp it yet :)
The most obvious reason is that NetworkStream inherits Stream, which means
you can hook your network i/o object to any input or output that can use a
Stream. By abstracting the Socket class to a Stream class, you can then
use the Socket with a wide variety of classes that need to know nothing
about Socket.
There are some subtle differences in the semantics between Socket and
Stream as well, but IMHO the above abstraction issue is the major reason
for it existing. It's very convenient.
Pete