Byte Array Conversion

I'm trying to read data after making a winsock call.  the data I get back is a byte array.  the problem i'm having is the data is mixed data types.  I can't just convert it all to strings as it has integer, byte, string, and float datatypes.  I'm not sure how to go about parsing this byte array to get the data i need.  I beleve the data is chr(0) seperated but the problem is the integer can have a 0 value.  I'm not sure how to tell the two apart in a byte array.  any help would be great

the format is . . .
      Server responds with the following packet:
      (int32)            -1
      (byte)            ASCII 'D' (players response, S2A_PLAYER)
      (byte)            active client count

      for each active client
            (byte)            client number / index
            (string)            player name
            (int32)            client's frag total
            (float32)            client's total time in-game
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

why can you dim it as "any"?
luige34Author Commented:
I don't know what "any" is?  Please explain.
luige34Author Commented:
Oh, any only works with the Declare Statement
luige34Author Commented:
Didn't Answer Question.
From your description:
(int32) -1
(byte) ASCII 'D'
(byte) active client count

 (byte) client number / index
 (string) player name
 (int32) client's frag total
 (float32) client's total time in-game

If this is correct, the only place that length varies is each string.  It is probably terminated with a null (char(0)) like you expect, but that's the only part.  the other parts are fixed in size.  You can count the other bytes, and always know whether a zero is a real value or the end of one of the strings.

So you would need to parse the byte array.  First toss out the top two values because you know what they mean.
then get the count.
Using the count, loop through getting the client data:

First, the number, one byte.
then the name, however many bytes it takes to reach the null character (and not including it)
then the two 32-bit numbers.

then repeat the loop, because the next byte will be the next client number/index

good luck with it,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.