Create NetworkStream from TcpClient : TcpClient : Network C# Examples


C# Examples » Network » TcpClient »

 

Create NetworkStream from TcpClient









    
using  System;
using  System.IO;
using  System.Net.Sockets  ;

class  MainClass
{
    public  static  void  Main()  
    {
        TcpClient  newSocket  =  new  TcpClient("localhost",  50001);

        NetworkStream  ns  =  newSocket.GetStream();

        byte[]  buf  =  new  byte[100];
        ns.Read(buf,  0,  100);

        char[]  buf2  =  new  char[100];
        for(int  i=0;i<100;i++)
            buf2[i]=(char)buf[i];
        Console.WriteLine(buf2);

        ns.Close();
        newSocket.Close();

    }

}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Network
» TcpClient