Network Streaming Client : NetworkStream « Network « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;

   public class Client
   {
      static public void Main( string[] Args )
      {
         TcpClient socketForServer = new TcpClient( "localHost", 65000 );
         NetworkStream networkStream = socketForServer.GetStream();
         System.IO.StreamReader streamReader = new System.IO.StreamReader( networkStream );
         string outputString;
         do{
           outputString = streamReader.ReadLine();

           if ( outputString != null )
           {
              Console.WriteLine( outputString );
           }
         }while ( outputString != null );
         networkStream.Close();
      }
   }








33.16.NetworkStream
33.16.1.Create a NetworkStream from a Socket
33.16.2.NetworkStream TcpClient
33.16.3.Use NetworkStream to read and write to a server
33.16.4.Tcp client: Use StreamReader and StreamWriter to read and write to a server
33.16.5.Network Streaming Client
33.16.6.Network Streaming Server