void xrun()
 {
     while (true)
     {
         IPEndPoint   clientIP = new IPEndPoint(IPAddress.Any, 00000);
         byte[]       data     = udp.Receive(ref clientIP);
         MemoryStream memsr    = new MemoryStream(data);
         Log2.Info(Encoding.ASCII.GetString(data));
         BinaryReader reader = new BinaryReader(memsr);
         if (data.Length > 4)
         {
             reader.ReadInt32(); // Clear the header...
             string type = Encoding.ASCII.GetString(reader.ReadBytes(data.Length - 4));
             if (type.Contains("heartbeat"))
             {
                 if (!type.Contains("flatline"))  //We still on...
                 {
                     int          a    = SendChallenge(clientIP, udp);
                     MemoryStream gsts = new MemoryStream();
                     BinaryWriter w    = new BinaryWriter(gsts);
                     w.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                     w.Write("getstatus " + a.ToString());
                     w.Flush();
                     byte[] bdata = gsts.ToArray();
                     udp.BeginSend(bdata, bdata.Length, clientIP, new AsyncCallback(Done), "GT-STS");
                 }
                 else
                 {
                     var cs = from cl in OnlineServers where cl.IP.ToString() == clientIP.ToString() select cl;
                     if (cs.Count() > 0)
                     {
                         Log2.Info("Client [" + cs.First().Configuration["sv_hostname"] + "] has been disconnected!");
                         OnlineServers.Remove(cs.First());  // Server removed!
                     }
                 }
             }
             if (type.Contains("statusResponse"))
             {
                 var cs = from cl in OnlineServers where cl.IP.ToString() == clientIP.ToString() select cl;
                 if (cs.Count() > 0)
                 {
                     int index = OnlineServers.IndexOf(cs.First());
                     OnlineServers[index] = new DedicatedClient(type, clientIP);
                     Log2.Info("Client [" + OnlineServers[index].Configuration["sv_hostname"] + "] has been updated.");
                 }
                 else
                 {
                     DedicatedClient dc = new DedicatedClient(type, clientIP);
                     OnlineServers.Add(dc);
                     Log2.Info("Connected client [" + dc.Configuration["sv_hostname"] + "].");
                 }
             }
             if (type.Contains("challengeResponse"))  // Do we really wanna mess up with this ?
             {
                 /*long chng = long.Parse(type.Split(' ')[1]);
                  * MemoryStream memsr2 = new MemoryStream();
                  * BinaryWriter writer = new BinaryWriter(memsr2);
                  * writer.Write(new byte[] { 0x00, 0xFF, 0xFF, 0xFF, 0xFF });  //Header
                  * writer.Write("getstatus");
                  * writer.Write(new byte[] { 0x02, 0x2D });
                  * writer.Write(chng);
                  * writer.Write(0x00);
                  * writer.Flush();
                  * byte[] fres = memsr2.ToArray();
                  * memsr2.Dispose(); //Stack saver?
                  * udp.BeginSend(fres, fres.Length, clientIP, new AsyncCallback(Done), "STS-REQ-" + chng.ToString());  // done with the chanllage shit!*/
             }
             if (type.Contains("getservers"))
             {
                 // Protocol Check
                 // 6 - Call of Duty 4
                 // 118 - Call of Duty 2
                 if (type.Split(' ')[1] == "6")
                 {
                     MemoryStream back = new MemoryStream();
                     BinaryWriter wr   = new BinaryWriter(back);
                     wr.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                     wr.Write(new byte[] { 0x67, 0x65, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6F, 0x6E, 0x73, 0x65 });
                     //wr.Write(new byte[] { 0x0A, 0x00 });  // Ermm.. magic number ?
                     wr.Write((byte)0x5C);
                     if (OnlineServers.Count > 0)
                     {
                         foreach (var cl in OnlineServers)
                         {
                             byte[] ip = cl.IP.Address.GetAddressBytes();
                             wr.Write(ip);
                             wr.Write((short)cl.IP.Port);
                         }
                     }
                     wr.Write((byte)0x5C);
                     wr.Write(new byte[] { 0x45, 0x4f, 0x66 });
                     wr.Flush();
                     byte[] servs = back.ToArray();
                     udp.BeginSend(servs, servs.Length, clientIP, new AsyncCallback(Done), "GT-SERVERS");
                 }
             }
             if (type.Contains("getIpAuthorize"))
             {
                 string[]     parts  = type.Split(' ');
                 MemoryStream memsr2 = new MemoryStream();
                 BinaryWriter writer = new BinaryWriter(memsr2);
                 writer.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                 writer.Write("ipAuthorize ");
                 writer.Write(parts[1] + " ");
                 writer.Write("accept KEY_IS_GOOD");
                 writer.Flush();
                 byte[] final = memsr2.ToArray();
                 udp.BeginSend(final, final.Length, clientIP, new AsyncCallback(Done), "IP-ACCEPT");
             }
         }
         else
         {
             Log2.Data("Unkown packet?");
         }
     }
 }
        void xrun()
        {
            while (true)
            {
                IPEndPoint clientIP = new IPEndPoint(IPAddress.Any, 00000);
                byte[] data = udp.Receive(ref clientIP);
                MemoryStream memsr = new MemoryStream(data);
                Log2.Info(Encoding.ASCII.GetString(data));
                BinaryReader reader = new BinaryReader(memsr);
                if(data.Length > 4)
                {
                    reader.ReadInt32(); // Clear the header...
                    string type = Encoding.ASCII.GetString(reader.ReadBytes(data.Length - 4));
                    if (type.Contains("heartbeat"))
                    {
                        if(!type.Contains("flatline"))  //We still on...
                        {
                            int a = SendChallenge(clientIP, udp);
                            MemoryStream gsts = new MemoryStream();
                            BinaryWriter w = new BinaryWriter(gsts);
                            w.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                            w.Write("getstatus " + a.ToString());
                            w.Flush();
                            byte[] bdata = gsts.ToArray();
                            udp.BeginSend(bdata, bdata.Length, clientIP, new AsyncCallback(Done), "GT-STS");
                        }
                        else
                        {
                            var cs = from cl in OnlineServers where cl.IP.ToString() == clientIP.ToString() select cl;
                            if (cs.Count() > 0)
                            {
                                Log2.Info("Client [" + cs.First().Configuration["sv_hostname"] + "] has been disconnected!");
                                OnlineServers.Remove(cs.First());  // Server removed!
                            }
                        }
                    }
                    if (type.Contains("statusResponse"))
                    {
                        var cs = from cl in OnlineServers where cl.IP.ToString() == clientIP.ToString() select cl;
                        if (cs.Count() > 0)
                        {
                            int index = OnlineServers.IndexOf(cs.First());
                            OnlineServers[index] = new DedicatedClient(type, clientIP);
                            Log2.Info("Client [" + OnlineServers[index].Configuration["sv_hostname"] + "] has been updated.");
                        }
                        else
                        {
                            DedicatedClient dc = new DedicatedClient(type, clientIP);
                            OnlineServers.Add(dc);
                            Log2.Info("Connected client [" + dc.Configuration["sv_hostname"] + "].");
                        }

                    }
                    if(type.Contains("challengeResponse"))  // Do we really wanna mess up with this ?
                    {
                        /*long chng = long.Parse(type.Split(' ')[1]);
                        MemoryStream memsr2 = new MemoryStream();
                        BinaryWriter writer = new BinaryWriter(memsr2);
                        writer.Write(new byte[] { 0x00, 0xFF, 0xFF, 0xFF, 0xFF });  //Header
                        writer.Write("getstatus");
                        writer.Write(new byte[] { 0x02, 0x2D });
                        writer.Write(chng);
                        writer.Write(0x00);
                        writer.Flush();
                        byte[] fres = memsr2.ToArray();
                        memsr2.Dispose(); //Stack saver?
                        udp.BeginSend(fres, fres.Length, clientIP, new AsyncCallback(Done), "STS-REQ-" + chng.ToString());  // done with the chanllage shit!*/
                    }
                    if(type.Contains("getservers"))
                    {
                        // Protocol Check
                        // 6 - Call of Duty 4
                        // 118 - Call of Duty 2
                        if(type.Split(' ')[1] == "6")
                        {
                            MemoryStream back = new MemoryStream();
                            BinaryWriter wr = new BinaryWriter(back);
                            wr.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                            wr.Write(new byte[] { 0x67, 0x65, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6F, 0x6E, 0x73, 0x65 });
                            //wr.Write(new byte[] { 0x0A, 0x00 });  // Ermm.. magic number ?
                            wr.Write((byte)0x5C);
                            if(OnlineServers.Count > 0)
                            {
                                foreach (var cl in OnlineServers)
                                {
                                    byte[] ip = cl.IP.Address.GetAddressBytes();
                                    wr.Write(ip);
                                    wr.Write((short)cl.IP.Port);
                                }
                            }
                            wr.Write((byte)0x5C);
                            wr.Write(new byte[] { 0x45, 0x4f, 0x66 });
                            wr.Flush();
                            byte[] servs = back.ToArray();
                            udp.BeginSend(servs, servs.Length, clientIP, new AsyncCallback(Done), "GT-SERVERS");
                        }
                    }
                    if(type.Contains("getIpAuthorize"))
                    {
                        string[] parts = type.Split(' ');
                        MemoryStream memsr2 = new MemoryStream();
                        BinaryWriter writer = new BinaryWriter(memsr2);
                        writer.Write(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                        writer.Write("ipAuthorize ");
                        writer.Write(parts[1] + " ");
                        writer.Write("accept KEY_IS_GOOD");
                        writer.Flush();
                        byte[] final = memsr2.ToArray();
                        udp.BeginSend(final, final.Length, clientIP, new AsyncCallback(Done), "IP-ACCEPT");
                    }
                }
                else
                {
                    Log2.Data("Unkown packet?");
                }
            }
        }