Author Topic: [BNET/RB] Buffering the "literal data"  (Read 3435 times)

0 Members and 1 Guest are viewing this topic.

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
[BNET/RB] Buffering the "literal data"
« on: September 02, 2005, 09:36:46 pm »
It took me a while, but I finally figured out why I only get a 0x25 (Ping, or ASCII 37, I hope...) and I do not get a reply to 0x50...

If packets are sent that close together, and I call ReadAll from my socket, it gets both packets in one message.

So I tried to write a little buffer, which failed, because I still only get a packet with the ID of ASCII 37...

Here is what I thought up:

Code: [Select]
  dim mypacket as new ParsePacket
  dim s, ss as string
 
    s = me.ReadAll
    if CountFields(s, chr(&HFF)) - 1 = 1 then
      // We just have one packet... Lucky us!
    else
      // More then one packet, so parse
      while CountFields(s, chr(&HFF)) - 1 <> 0
        ss = ss + leftb(s, 1)
        s = midb(s, 2)
        if LenB(ss) > 1 then
          if asc(rightb(s, 1)) = &HFF then
            s = chr(&HFF) + s
            ss =left(ss, len(ss) - 1)
            mypacket.UseData ss
            mypacket = new ParsePacket
          end if
        end if
      wend
    end if

I quickly found out I was doing something dead wrong, and there must be a better way.

Please help, and, as always, thanks in advance.
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00

Offline Ryan Marcus

  • Cross Platform.
  • Full Member
  • ***
  • Posts: 170
  • I'm Bono.
    • View Profile
    • My Blog
Re: [BNET/RB] Buffering the "literal data"
« Reply #1 on: September 03, 2005, 10:34:25 am »
Never-mind.. Much better way:

Code: [Select]
    Packets = Split(me.ReadAll, chr(&HFF))
    if Packets(0) = "" then
      Packets.Remove(0)
    end if
    while UBound(Packets) <> -1
      mypacket.UseData chr(&HFF) + Packets(0)
      Packet(mypacket)
      mypacket = new ParsePacket
      if UBound(Packets) <> -1 then
        Packets.Remove(0)
      end if
    wend
Thanks, Ryan Marcus

Quote
<OG-Trust> I BET YOU GOT A CAR!
<OG-Trust> A JAPANESE CAR!
Quote
deadly: Big blue fatass to the rescue!
496620796F75722072656164696E6720746869732C20796F75722061206E6572642E00