Returns the NetworkStream used to send and receive data.

      Syntax

      public NetworkStream GetStream()

      Return Value

      The underlying NetworkStream.

      Examples

      Shows how to use Connect and GetStream methods to send a request to a server and read response from the server.

      using System;
      using System.IO;
      using System.Net.Sockets;
      using System.Windows.Forms;
      using ComponentPro.Net;
      
      ...
      
      try
      {
          // Initialize request message. 
          string requestMessage =
              "GET / HTTP/1.0\r\n" +
              "Host: www.google.com\r\n" +
              "Connection: close\r\n" +
              "\r\n";
      
          // Create a new instance of the ProxyClient. 
          using (ProxyClient proxyClient = new ProxyClient(ProxyType.HttpConnect, ProxyHttpConnectAuthMethod.Basic,
                  "10.0.0.6", 808, "thang", "1234", null))
          {
              proxyClient.Connect("google.com", 80);
              NetworkStream nsr = proxyClient.GetStream();
      
              // Send request. 
              StreamWriter streamWriter = new StreamWriter(nsr);
              streamWriter.Write(requestMessage);
              streamWriter.Flush();
      
              // Print out response. 
              StreamReader streamReader = new StreamReader(nsr);
              Console.Write(streamReader.ReadToEnd());
          }
      }
      catch (Exception exc)
      {
          MessageBox.Show(string.Format("An error occurred: {0}", exc.Message));
      }

      Framework

      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.Network.CF (in ComponentPro.Network.CF.dll)

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.Network (in ComponentPro.Network.dll)

      Xamarin AndroidXamarin Android

      Supported version: 2.3 and later
      Assembly: ComponentPro.Network.Android (in ComponentPro.Network.Android.dll)

      Xamarin MacXamarin Mac

      Supported version: 2.0.x and later
      Assembly: ComponentPro.Network.Mac (in ComponentPro.Network.Mac.dll)

      Xamarin iOSXamarin iOS

      Supported version: 5.1.x and later
      Assembly: ComponentPro.Network.iOS (in ComponentPro.Network.iOS.dll)

      See Also