Networking with Streams

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

LISTING 18.2 Networking with NetworkStream

Imports System.Net.SocketsImports System.TextModule Network    Sub NetStreamDemo()        'Instantiating TcpClient and NetworkStream        Dim customTcpClient As New TcpClient()        Dim customNetworkStream As NetworkStream        Try            'Attempt ...

Get Visual Basic 2015 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.