• Welcome to Valhalla Legends Archive.
 

0x0F User_InChannel

Started by Blaze, August 11, 2004, 11:01 PM

Previous topic - Next topic

doomy

$torm is that java or C? somtimes they look exactly the same...meh i use java cause im lazy and like using premade classes

Banana fanna fo fanna

psuedocode.......................

Adron

Quote from: $t0rm on August 15, 2004, 07:30 PM
Whoops, knew I forgot something...

messageid = 0
messagelen = -1
buffer = new ByteBuffer()
while (socket.connected) {
   buffer.append(socket.readdata())
   [b]while[/b] messagelen == -1 {
       if buffer.position >= 4 {
           hdr = buffer.read(4)
           messageid = hdr[1]
           messagelen = bytes2word(hdr[2],hdr[3])
       }
   }
   if messagelen != -1 && buffer.position >= messagelen {
       handle_message(messageid, buffer.read(messagelen))
       messageid = -1
   }
}


Umm, not all that much better? Needs to loop the whole read?

How about this for solving that?


messageid = 0
messagelen = -1
buffer = new ByteBuffer()
while (socket.connected) {
   buffer.append(socket.readdata())
   do {
     if messagelen == -1 {
         if buffer.position >= 4 {
             hdr = buffer.read(4)
             messageid = hdr[1]
             messagelen = bytes2word(hdr[2],hdr[3])
         }
     }
     if messagelen != -1 && buffer.position >= messagelen {
         handle_message(messageid, buffer.read(messagelen))
         messageid = -1
     }
  } while messageid == -1 && buffer.position >= 4
}

Banana fanna fo fanna

bah, didn't look at it close enough; thought the while encompassed the second part.

Blaze

Quote from: $t0rm on August 15, 2004, 04:44 PM
Quote from: Kk)Blaze(kK on August 15, 2004, 12:40 PM
I know too little of C to translate and I am too lazy to see if there is a program to do it. On the finishing note, I am Lazy.

i fucking hate you and i'm never helping you again.

it's easy as hell to read, even for the vb "programmer" that you are. if you'd rather copy someone elses code and then get bitched off the forum cause everyone hates you, that's your business.

good bye.

If I can't read why didn't you read this?


Quote from: Kk)Blaze(kK on August 15, 2004, 03:22 AM
(Maybe I shouldn't just skim-read....)
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

Banana fanna fo fanna

Quote from: Kk)Blaze(kK on August 15, 2004, 12:40 PM
I know too little of C to translate and I am too lazy to see if there is a program to do it. On the finishing note, I am Lazy.

I took time out of my day and thought about that and typed it out for you. I could've been doing something else, but I decided to help you because you were new. Won't make that mistake again...

|