1try {
2 TcpClient tcpclnt = new TcpClient();
3 Console.WriteLine("Connecting.....");
4
5 tcpclnt.Connect("192.168.0.2",8001); // use the ipaddress as in the server program
6
7 Console.WriteLine("Connected");
8 Console.Write("Enter the string to be transmitted : ");
9
10 String str=Console.ReadLine();
11 Stream stm = tcpclnt.GetStream();
12
13 ASCIIEncoding asen= new ASCIIEncoding();
14 byte[] ba=asen.GetBytes(str);
15 Console.WriteLine("Transmitting.....");
16
17 stm.Write(ba,0,ba.Length);
18
19 byte[] bb=new byte[100];
20 int k=stm.Read(bb,0,100);
21
22 for (int i=0;i<k;i++)
23 Console.Write(Convert.ToChar(bb[i]));
24
25 tcpclnt.Close();
26}
27
28 catch (Exception e)
29 {
30 Console.WriteLine("Error..... " + e.StackTrace);
31 }
32