MrLucky Posted May 12, 2006 Posted May 12, 2006 I'm busy with an app that can get some information about a CS:S server. http://www.int64.org/docs/gamestat-protocols/source.html Here's a page about the protocol. But, my question is: how can I send the query? do I have to create a byte array with the query? or is there another way? Quote
Gill Bates Posted July 4, 2006 Posted July 4, 2006 Yeah, you will need to send the raw bytes for the query. Since they give the query structure in hex you will simply need to convert it to standard bytes. Here's a method I came up with to do that:private byte[] GetBytes(string hex) { System.Collections.Generic.List<byte> bytes = new List<byte>(); foreach (string hexChunk in System.Text.RegularExpressions.Regex.Split(hex.Trim(), @"\s+")) { bytes.Add((byte)Int32.Parse(hexChunk, System.Globalization.NumberStyles.HexNumber)); } return bytes.ToArray(); }Example call:foreach (byte b in GetBytes("FF FF FF FF 55")) { System.Diagnostics.Debug.WriteLine(b); }Once you figure out the byte structure you can just hard code the queries like the following:byte[] detailsQuery = new byte[] { 255, 255, 255, 255, 54 }; byte[] rulesQuery = new byte[] { 255, 255, 255, 255, 86 }; byte[] playersQuery = new byte[] { 255, 255, 255, 255, 85 }; You can then just send the query like the following:mySocket.Send(detailsQuery);You will get back a stream of bytes that is structured as they described on that page. Reading it should be easy. The only tricky part will be the strings. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.