title: How to write the UDP data which is send from another ip address into text file without lost losing any data
body: <p>Actually in console.writeline i am getting all the data from UDPserver which is send from another ipaddress . While writing that transfered data into my text file somes data is missing it doesn't write so how to write that data into my textfile without lost </p>
  
  <pre><code>bool done = false;
  private const int listenPort = 9050;
  string strDestinationfileName = AppDomain.CurrentDomain.BaseDirectory + "Sample.txt";
  UdpClient listener = new UdpClient(listenPort);
  IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);
  FileStream fout = new FileStream(strDestinationfileName,   
                                   FileMode.OpenOrCreate,
                                   FileAccess.Write, FileShare.ReadWrite);
  try
  {
      while (!done)
      {
          Console.WriteLine("Waiting for broadcast");
          byte[] bytes = listener.Receive(ref groupEP);
          fout.Write(bytes, 0, bytes.Length);
          System.Threading.Thread.Sleep(100);
  
          Console.WriteLine("Received broadcast from {0} :\n {1}\n",
              groupEP.ToString(),
              Encoding.ASCII.GetString(bytes, 0, bytes.Length));
      }
  }
  </code></pre>