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

namespace BufferedStreamClient
{
    class Program
    {
        static void Main(string[] args)
        {
            //Client liest Daten ein
            Console.WriteLine("Client");

            IPAddress ipadr = IPAddress.Parse("127.0.0.1");
            TcpListener tcpListener = new TcpListener(ipadr, 9000);
            tcpListener.Start();
            Socket socket = tcpListener.AcceptSocket();

            if (socket.Connected)
            {
                NetworkStream ns = new NetworkStream(socket);
                Stream bufferd = new BufferedStream(ns, 10);
                UnicodeEncoding ue = new UnicodeEncoding();

                byte[] readBytes = new byte[10];

                for (int i = 0; i < 10; i++)
                {
                    bufferd.Read(readBytes, i, 1);
                }

                string receive = ue.GetString(readBytes);
                Console.WriteLine(receive);
            }

            socket.Close();
            Console.ReadLine();
        }
    }
}
