.net - What is the difference between NetworkStream and Socket classes? -


i have project might want abstract communication between client , server. using sockets , tcp. thought might nice able switch inter process communication channel. looked @ system.io.pipedstream class , saw there lot of overlap between pipestream , socket class. when had @ socket class inherits object. there no common interface or abstract class between socket , pipestreams.

i remembered networkstream. apparently wraps socket class. @ least both networkstream , pipestream inherit stream. means can swap implementation out. think, haven't tried yet. have been using sockets time.

so question is: there disadvantage using networkstream class on socket class. gotchas or watch out for?

if forced use low level options such sockets , pipes, , want abstraction pulling streaming data data sources stream class perfect, provides abstraction model.

if code against stream instances, can have implement stream, , not worry underlying transport.

in reference using networkstream vs socket, networkstream wraps socket instance , applies calls pull model (the stream) socket.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -