Author Topic: [C#] Packet Buffer & Parser  (Read 13029 times)

0 Members and 1 Guest are viewing this topic.

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: [C#] Packet Buffer & Parser
« Reply #15 on: December 08, 2006, 07:39:04 pm »
That means that your "len" variable is less than 0.
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline Smarter

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [C#] Packet Buffer & Parser
« Reply #16 on: December 08, 2006, 08:38:19 pm »
Any idea why?

Offline Smarter

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [C#] Packet Buffer & Parser
« Reply #17 on: December 09, 2006, 12:12:25 am »
Ok, i'm stumped, my buffer is like empty, always, no idea why, sorry for all the help ?'s but I'm eager to get this to work!:

Code: [Select]
        public void OnConnect()
        {
            sckBNET = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            sckBNLS = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            sckBNET.Connect("useast.battle.net", 6112);
            sckBNLS.Connect("bnls.valhallalegends.com", 9367);
            //watch for data ( asynchronously )...
            AddC("[BNLS]: Connecting...");
            AddC("[BNET]: Connecting...");
            if (sckBNET.Connected == true)
            {
                AddC("[BNET]: Connected.");
            }
            if (sckBNLS.Connected == true)
            {
                AddC("[BNLS]: Connected.");
            }
            DataBuffer x0 = new DataBuffer();
            x0.InsertByte(0);
            byte[] x = x0.GetData();
            sckBNET.Send(x);
            DataBuffer buf = new DataBuffer();
            int procid = 0;
            buf.InsertInt32(procid);
            string platformid = "IX86";
            buf.InsertDwordString(platformid);
            string productid = "PXES";
            buf.InsertDwordString(productid);
            byte version = 0xCF;
            buf.InsertByte(version);
            buf.InsertInt32(0);
            buf.InsertInt32(0);
            buf.InsertInt32(0);
            buf.InsertInt32(0);
            buf.InsertInt32(0);
            buf.InsertCString("USA");
            buf.InsertCString("United States");
            byte[] p50 = buf.GetData();
            sckBNET.Send(p50);
            AddC("C > S - 0x50 SID_AUTH_INFO!");
            WaitForData();
           
        }
Code: [Select]
public void WaitForData()
        {
            // now start to listen for any data...
            m_asynResult = sckBNET.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, pfnCallBack, null);
            m_asynResult2 = sckBNLS.BeginReceive(bnlsbufr, 0, bnlsbufr.Length, SocketFlags.None, pfnCallBack2, null);
            if (pfnCallBack == null)
                pfnCallBack = new AsyncCallback(OnDataReceived);
            //if (pfnCallBack2 == null)
            //    pfnCallBack2 = new AsyncCallback(OnDataReceived);
           
        }
Code: [Select]
public void OnDataReceived(IAsyncResult asyn)
        {
            int len = BitConverter.ToInt16(buffer, 2) - 4;
            byte[] data = new byte[512];
            if (len < 0)
            {
                sckBNET.Receive(buffer, 0, SocketFlags.None);
            }
            HandlePacket(buffer[1], data, len);
            //end receive...
            int iRx = 0;
            iRx = sckBNET.EndReceive(asyn);

            WaitForData();
        }

There's my socket stuff....?