I have two buffers, one is the "input" buffer, and I use it to do a recv from the socket. The second buffer is used in a for loop. I loop from 0 to the length of the recv buffer and add characters one at a time to the processing buffer. When I get 4 bytes I check what ComType the message is. I then keep looping until the processing buffer has the same amount of bytes as whatever com object the message is. I then cast the buffer to the proper type and pass it to the scripting engine to handle.
The bug was I was checking the recv buffer for the comtype and not the processing buffer, so when I got multiple messages in one recv, it was treating all of them as the first message type. But it's fixed now and works happily.
When I left last night I ended up being out till after 1 am, I fell asleep around 2 am. I got up at 6:30 am for work, so I'm beat.
I haven't watched tv in a week and a half so I am going to go fire up the tivo and watch the new episode of stargate and atlantis I missed on friday. Then I'm going to sleep.