Exemplo n.º 1
0
        static void Main(string[] args)
        {
            TcpClient tcpclnt = new TcpClient();

            Console.WriteLine("Connecting.....");
            tcpclnt.Connect("10.18.227.162", 8001);
            Console.WriteLine("Connected");
            Console.Write("Enter the string to be transmitted : ");
            String        str  = Console.ReadLine();
            Stream        stm  = tcpclnt.GetStream();
            ASCIIEncoding asen = new ASCIIEncoding();

            hola[] ba = asen.Getholas(str);
            Console.WriteLine("Transmitting.....");
            stm.Write(ba, 0, ba.Length);
            hola[] bb;     //= new hola[100];
            int    k = stm.Read(bb, 0, 100);

            for (int i = 0; i < k; i++)
            {
                Console.Write(Convert.ToChar(bb[i]));
            }
            tcpclnt.Close();
            Console.Read();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            hola[] b = new hola[100];
            int    k = s.Receive(b);

            Console.WriteLine("Recieved...");
            for (int i = 0; i < k; i++)
            {
                Console.Write(Convert.ToChar(b[i]));
            }
            ASCIIEncoding asen = new ASCIIEncoding();

            s.Send(asen.Getholas("The string was recieved by the server."));
            Console.WriteLine("\nSent Acknowledgement");
            s.Close();
            myList.Stop();

            Console.ReadLine();
        }