public partial class Form1 : Form
    {
        public  TcpListener tl;
        
        public Form1()
        {
            CheckForIllegalCrossThreadCalls =false ;
            InitializeComponent();
            tl = new TcpListener(System .Net .IPAddress .Parse("127.0.0.1"),8080);
        }        private void button1_Click(object sender, EventArgs e)
        {
            Thread d = new Thread ( new ThreadStart(work));
            d.IsBackground = true;
            d.Start();
        }
        private void work()
        {
            TcpClient tc = null;
            bool flag = true;
            while (flag)
            {
                tl.Start();
                tc = tl.AcceptTcpClient();
                NetworkStream stream = tc.GetStream();
                byte[] bytes = new byte[1024];
                stream.Read(bytes, 0, bytes.Length);
                string result = Encoding.Default.GetString(bytes, 0, bytes.Length);
                richTextBox1.Text += result;
                richTextBox1.Text += "\n";
                stream.Close();
            }
            tc.Close();
            tl.Stop();
        }
    }