IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-10-24 20:19:38
Channels: 41
Logged Lines: 6230436
Size: 1822.27 MB
Powered by
Channel Info
Network: freenodeChannel: #csharp |
Search in www.irclog.org
Log from #csharp at freenode 2006-07-04
[14:03]<ddx>well, let me restate my problem clearly and you guys let me know if that'd be easiest
[14:04]<ddx>I send a server a udp packet with a query, and it replies with "header\(6 bytes)\(6 bytes)\ .. \EOT"
[14:04]<rwyfcygs>Hmm, that's a point, can you attach more than one StreamReader to the same stream and alternate, like use TextReader to get the text parts and then use ByteReader to grab the IPs?
[14:04]<ddx>Hmm
[14:04]<ddx>It sound very feasible
[14:05]<ddx>can you make 'a stream' from just a chunk of bytes though?
[14:05]<rnzrnf_->yes
[14:05]<ddx>mkay
[14:05]<rwyfcygs>MemoryStream ms = new MemoryStream(byteArray);
[14:07]<ddx>ok
[14:07]<ddx>heres a little side problem while we're on topic
[14:07]<ddx>the query is "ÿÿÿÿgetservers Warsow 7"
[14:08]<ddx>UdpClient.Send() requres a byte[] however, quick way to go string->byte[] ?
[14:08]<ddx>I was just doing this, one sec, heh
[14:09]<rwyfcygs>Eerrrrrrrrrm Encoding.ASCII.GetBytes() ?
[14:09]<mjzymygo>awilkins: that can do funny things to any byte >127 as ASCII standard only covers the first 128
[14:09]<pfrsdr>dmh, umm, split the string by the delimiter \ ?
[14:10]<pfrsdr>check out uhhh dev.kquery.com
[14:10]<ddx>Plasma, yes I was doing that
[14:10]<zyccus>you have to know the encoding, as ever
[14:10]<pfrsdr>thats the quake3 protocol they are using
[14:10]<pfrsdr>slightly modified
[14:10]<ddx>I'm familiar with the kquery stuff
[14:10]<pfrsdr>sourcecode in qstat - www.qstat.org you may want to check out
[14:10]<ddx>this is for warsow however
[14:10]<pfrsdr>yeah, checkout qstat - it has support
[14:10]<ddx>mm yea I'll have to check those out
[14:10]<ddx>but what is it written in?
[14:10]<pfrsdr>(qstat is a free/open source serverq tool)
[14:10]<pfrsdr>c I think or c++
[14:10]<ddx>ok
[14:11]<pfrsdr>what issue are you having specifically ? I joined the channel late
[14:12]<ddx>just the generally easiest way to parse "header\(6 bytes)\(6 bytes)\ .. \EOT"
[14:12]<ddx>TextReader an MemoryStream may be the money
[14:12]<ddx>holy
[14:12]<ddx>its 5:10AM
[14:12]<pfrsdr>well, I would imagine just put it in a string
[14:12]<pfrsdr>then explode it with string.split
[14:12]<ddx>I better get to sleep, I got some serious BBQs to go to
[14:12]<ddx>yes, thats what I was first doing
[14:12]<pfrsdr>at least then you know 0 has the header, 1 has teams... etc
[14:12]<ddx>I had errornous encoding however
[14:12]<pfrsdr>then if needed, explode the bits again (eg, to get a key=valyue combo)
[14:13]<ddx>its just (6 bytes), ip / port
[14:13]<ddx>querying master server right now
[14:13]<pfrsdr>yes
[14:13]<pfrsdr>the ip and port are packed integers
[14:13]<ddx>right
[14:13]<pfrsdr>port is 2 integers
[14:13]<ddx>i got all this figured out
[14:13]<pfrsdr>ip address is 2 as well
[14:13]<ddx>ip is 4
[14:13]<pfrsdr>4 bytes for IP
[14:13]<pfrsdr>yes
[14:13]<ddx>I was just doing it the hard way
[14:13]<pfrsdr>hang a sec
[14:14]<ddx>but yea I'm going to bed
[14:14]<ddx>?
[14:14]<pfrsdr>waiiit one sec
[14:14]<ddx>string[] chunks = serverData.Split('\\'); then processed each in a foreach
[14:14]<pfrsdr>traditionally I think the ip would be the character code for the ip for each byte
[14:14]<pfrsdr>so,
[14:14]<pfrsdr>ip = chr(bit[0]) + "." + chr(bit[1]) .....
[14:15]<ddx>i had
[14:15]<pfrsdr>port being packed, doing this in php would be something like:
[14:15]<ddx>here i'll show you
[14:15]<pfrsdr>2 bytes for port. first byte and second byte differ:
[14:15]<ddx>http://rafb.net/paste/results/Gi3vLH31.html
[14:15]<ddx>I know this man
[14:15]<ddx>thats not the issue at hand
[14:15]<pfrsdr>yeh ok
[14:16]<ddx>but thanks anyway :]
[14:16]<pfrsdr>ok :]
[14:16]<pfrsdr>oh, one other thing
[14:16]<pfrsdr>traditionally, the byte before each variable length string, is the size of the string that follows
[14:16]<pfrsdr>so you could possibly just walk the entire string, going to the start position and going from there
[14:17]<pfrsdr>instead of splitting anything
[14:17]<ddx>hrm
[14:17]<ddx>as far as i know
[14:17]<ddx>well it is a set size between each, but no set size on teh query
[14:17]<ddx>like
[14:18]<ddx>"ÿÿÿÿgetserversResponse\...(6 bytes)...\...(6 bytes)...\EOT"
[14:18]<mjzymygo><Plasma> traditionally, the byte before each variable length string, is the size of the string that follows
[14:18]<mjzymygo>^^^ yeh... right!
[14:18]<ddx>but sometimes I get 10 6 byte sections, sometimes 15, etc
[14:18]<ddx>walking the string would still be very easy
[14:18]<ddx>and thats why i'm looking into some stream classes
[14:18]<ddx>but now I *really* need to go to bed, we can talk about it later perhaps
[14:19]<mjzymygo>dmh: what your trying to achieve is actually not a hard job, but non of us here are going to give you your answer as we are all busy
[14:19]<pfrsdr>:)
[14:19]<pfrsdr>night dmh
[14:19]<ddx>Moridin8, I dont want spoon fed code
[14:19]<ddx>in fact
[14:19]<ddx>what you've guys corrected me on tonight is more then enough
[14:19]<ddx>I'll get it all sorted tomorrow with a more clear head for sure
[14:20]<mjzymygo>retrieve byte array. stick it in a memorystream... walk it, parse it
[14:20]<pfrsdr>dmh, one last tip!
[14:20]<pfrsdr>just grab a few example queries
[14:20]<pfrsdr>and lay them out in notepad or something
[14:20]<ddx>Moridin8, thats what I was planning heh







