Receiving packets

09/24/2011 11:17 BaussHacker#1
When I receive a packet I do something like this:
Code:
        public static void NewPacket(SocketClient Client, byte[] Packet)
        {
                        if (Kernel.SafePacket(Client, Packet))
                        {
                        //Handle
                        }
            }
Code:
        public static bool SafePacket(SocketClient Client, byte[] Packet)
        {
            if (Client == null || Packet == null)
                return false;

            return (Packet.Length > 0 && Packet.Length <= MaxPacketSize);
        }
But would it take more resources or it wouldn't matter, if so is there other ways that's better?
09/24/2011 17:34 12tails#2
well... other thing you could do is:

Code:
        public static bool SafePacket(SocketClient Client, byte[] Packet)
        {
            if (Client == null || Packet == null)
                return false;

            if (Packet.Length > 0 && Packet.Length <= MaxPacketSize);
            {
                Proccess(Client, Packet);
                return true;
            }
            else return false;
        }
             //----------------------------------

            static void Proccess(SocketClient Client, byte[] Packet)
            {
                        //Handle
            }
09/24/2011 18:05 BaussHacker#3
Quote:
Originally Posted by 12tails View Post
well... other thing you could do is:

Code:
        public static bool SafePacket(SocketClient Client, byte[] Packet)
        {
            if (Client == null || Packet == null)
                return false;

            if (Packet.Length > 0 && Packet.Length <= MaxPacketSize);
            {
                Proccess(Client, Packet);
                return true;
            }
            else return false;
        }
             //----------------------------------

            static void Proccess(SocketClient Client, byte[] Packet)
            {
                        //Handle
            }
Would do no difference xD
09/24/2011 18:11 _tao4229_#4
doesn't matter in the least (maybe if you're worrying about 100s of cpu cycles, if so you shouldn't be using C#), you've got bigger problems to worry about.
09/24/2011 18:48 BaussHacker#5
Quote:
Originally Posted by _tao4229_ View Post
doesn't matter in the least (maybe if you're worrying about 100s of cpu cycles, if so you shouldn't be using C#), you've got bigger problems to worry about.
The bigger problems is? xD
09/24/2011 21:33 Spirited#6
Shouldn't your packet splitter be doing this?
*if you have one. There are other ways of splitting packets.

Look at Kibou if you're interested. I removed it recently because of a Turk that tried releasing it. If you need it, just msn me or comment on my blog.
09/24/2011 21:37 BaussHacker#7
Quote:
Originally Posted by Fаng View Post
Shouldn't your packet splitter be doing this?
*if you have one. There are other ways of splitting packets.

Look at Kibou if you're interested. I removed it recently because of a Turk that tried releasing it. If you need it, just msn me or comment on my blog.
Not using a packetsplitter. And sure I would like to take a look, thanks ^^
09/24/2011 22:12 Arco.#8
Just take a look at Kibou, Kanji. They are perfect.
09/24/2011 22:15 Spirited#9
Quote:
Originally Posted by Arco. View Post
Just take a look at Kibou, Kanji. They are perfect.
.-. There's no such thing has "perfect"...
And I've learned a lot since Kibou and Kanji.
09/24/2011 22:16 Yup Stigs#10
My long, lost brother is back.

/ontopic

" " //Kibou has a great example