Packet Strcuture Example

02/02/2012 05:39 shadowman123#1
Well i've read Korvacs wiki About packets Its Pretty Amazing So i checked How packet being build i decided i to look At Passwordcryptography Seed Strcuture i Found its like that in My Source

Code:
        byte[] Buffer;
        public PasswordCryptographySeed()
        {
            Buffer = new byte[8];
            Writer.WriteUInt16(8, 0, Buffer);
            Writer.WriteUInt16(1059, 2, Buffer);
        }
        public int Seed
        {
            get
            {
                return BitConverter.ToInt32(Buffer, 4);
            }
            set
            {
                Network.Writer.WriteInt32(value, 4, Buffer);
            }
        }
But what i Did is making Private ushort variable Named Seed Then Recalled it like that

Code:
byte[] Buffer;
        private ushort Seed;
        public PasswordCryptographySeed()
        {
            Buffer = new byte[8];
            Writer.WriteUInt16(8, 0, Buffer);
            Writer.WriteUInt16(1059, 2, Buffer);
            Writer.WriteUInt16(Seed, 4, Buffer);
        }
So The question is They r build in 2 ways but Same Result at final So does methods Affect on Socket ?? and is the 2nd way which i used is better then the 1st one or they r Exact same ?
02/02/2012 05:45 blaсkNull#2
With your new way, you'll never be able to set the seed.
02/02/2012 05:47 Spirited#3
You shouldn't have a ushort as the seed. It needs to be an int (though it'll work properly... TQ uses an int). To answer your question though, they're being built more or less in the same way. You're just writing the data at different times. The socket system only sees the resulting byte array... so it really doesn't matter how it becomes a byte array. The socket will treat it the same as any other byte array that you pass to it.

Quote:
Originally Posted by blaсkNull View Post
With your new way, you'll never be able to set the seed.
^
And that's completely true.
Your seed is private, thus you will not be able to access it.
02/02/2012 07:00 shadowman123#4
Quote:
Originally Posted by blaсkNull View Post
With your new way, you'll never be able to set the seed.
Quote:
Originally Posted by Fаng View Post
You shouldn't have a ushort as the seed. It needs to be an int (though it'll work properly... TQ uses an int). To answer your question though, they're being built more or less in the same way. You're just writing the data at different times. The socket system only sees the resulting byte array... so it really doesn't matter how it becomes a byte array. The socket will treat it the same as any other byte array that you pass to it.



^
And that's completely true.
Your seed is private, thus you will not be able to access it.
Thank you Guyz Stuffs r being Clarified and iam glad for that
02/02/2012 07:00 pro4never#5

<_<
02/03/2012 10:20 I don't have a username#6
You shouldn't focus much on how you STRUCTURE the packets, but how you HANDLE the packets. You should still focus a bit on it, but shouldn't be your biggest concern.

Like said above, the sockets will threat the result as the same.

Code:
byte[] packet = writepacketway1();//first way to structure packet, still a bytearray
byte[] packet2 = writepacketway2();//second way to structure packet, still a bytearray

socket.Send(packet);//sending first packet, it's the same as 2nd packet, no difference
socket.Send(packet2);//same goes here
So the way you structure packet is not what's really important and it's not what your sockets are relaying on. It's how you handle stuff in your server like queues, features etc.

You seriously need to look up at how C# works.