Returns the NetworkStream used to send and receive data.


      public NetworkStream GetStream()

      Return Value

      The underlying NetworkStream.


      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;
          // Initialize request message. 
          string requestMessage =
              "GET / HTTP/1.0\r\n" +
              "Host:\r\n" +
              "Connection: close\r\n" +
          // Create a new instance of the ProxyClient. 
          using (ProxyClient proxyClient = new ProxyClient(ProxyType.HttpConnect, ProxyHttpConnectAuthMethod.Basic,
                  "", 808, "thang", "1234", null))
              proxyClient.Connect("", 80);
              NetworkStream nsr = proxyClient.GetStream();
              // Send request. 
              StreamWriter streamWriter = new StreamWriter(nsr);
              // Print out response. 
              StreamReader streamReader = new StreamReader(nsr);
      catch (Exception exc)
          MessageBox.Show(string.Format("An error occurred: {0}", exc.Message));


      .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