public async Task <ServerInfoResult> GetServerInfo()
        {
            using (var client = new UdpClient(new IPEndPoint(IPAddress.Any, 0)))
            {
                client.Connect(EndPoint);
                var requestPacket = new List <byte>();
                requestPacket.AddRange(new Byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                requestPacket.Add(0x54);
                requestPacket.AddRange(Encoding.ASCII.GetBytes("Source Engine Query"));
                requestPacket.Add(0x00);
                await client.SendAsync(requestPacket.ToArray(), requestPacket.ToArray().Length);

                UdpReceiveResult response = await client.ReceiveAsync();

                return(ServerInfoResult.Parse(response.Buffer));
            }
        }
        public ServerInfoResult GetServerInfoSync(GetServerInfoSettings settings)
        {
            var localEndPoint = new IPEndPoint(IPAddress.Any, 0);

            using (var client = new UdpClient(localEndPoint))
            {
                client.Client.ReceiveTimeout = settings.ReceiveTimeout;
                client.Client.SendTimeout    = settings.SendTimeout;

                client.Connect(EndPoint);
                var requestPacket = new List <byte>();
                requestPacket.AddRange(new Byte[] { 0xFF, 0xFF, 0xFF, 0xFF });
                requestPacket.Add(0x54);
                requestPacket.AddRange(Encoding.ASCII.GetBytes("Source Engine Query"));
                requestPacket.Add(0x00);
                var requestData = requestPacket.ToArray();
                client.Send(requestData, requestData.Length);
                byte[] data = client.Receive(ref localEndPoint);
                return(ServerInfoResult.Parse(data));
            }
        }