Echo Client without message encoding : Socket Client : Network C# Examples


C# Examples » Network » Socket Client »

 

Echo Client without message encoding









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

class  MainClass
{
    const  int  echoPort  =  7;

    [STAThread]
    static  void  Main(string[]  args)
    {
        using  (  TcpClient  tc  =  new  TcpClient(  "localhost",  echoPort  )  )
        {
            NetworkStream  ns  =  tc.GetStream();
            StreamWriter  sw  =  new  StreamWriter(  ns  );
            StreamReader  sr  =  new  StreamReader(  ns  );

            sw.WriteLine(  "test  message"  );
            sw.Flush();
            System.Console.WriteLine(  sr.ReadLine()  );
        }
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Network
» Socket Client