Networking with Streams

The .NET Framework provides functionalities for data exchange through networks taking advantage of streams; in particular, it exposes the System.Net.Sockets.NetworkStream class. Basically reading and writing data via a NetworkStream instance passes through a System.Net.Sockets.TcpClient class’s instance. Code in Listing 19.2 shows how you can both write and read data in such a scenario. See comments in code for explanations.

Listing 19.2 Networking with NetworkStream

image

image

There are obviously several ways for data exchange, and ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.