Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C/C++

C/C++ C/C++ Discussion

Reply
 
Thread Tools Display Modes
Old 01-07-2008, 08:38 PM   #1 (permalink)
Account Terminated
 
Join Date: Dec 2007
Posts: 28
Default handling gzip packets

How are UO gzip packets handled? I know I need the zlib for whatever platform I'm using, but how do I know how big the packet is as its coming through? As in tcp packets are just streams, so you need to get up to a specific size, then handle the data to do whatever you need, in the case of a gzipped packet, it needs to be decompressed first. When I look at the char list for example, its a variable lenght packet and the size is specified, but I only know the size once I uncompress it, but I need to know the size so I can uncompress it, as I need to ensure I capture enough but not too much.
--w00t-- is offline   Reply With Quote
Old 01-07-2008, 09:00 PM   #2 (permalink)
Forum Expert
 
TheOutkastDev's Avatar
 
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,933
Default

I might be wrong on this but... Whenever a packet is compressed, it becomes a new packet that is identified by the Compressed Packet ID. This packet is just like any other packet. It has a length field which specifies the length of its contents which is the original packet after compression.
TheOutkastDev is offline   Reply With Quote
Old 01-07-2008, 09:06 PM   #3 (permalink)
Account Terminated
 
Join Date: Dec 2007
Posts: 28
Default

Hmm I could not find a lenght field, but maybe I was not looking properly. I'll have to analyze one of those packets again.
--w00t-- is offline   Reply With Quote
Old 01-13-2008, 10:34 PM   #4 (permalink)
Account Terminated
 
Join Date: Dec 2007
Posts: 28
Default

Hmm weird the lenght is not in there at all. Wonder if the only way is to use non blocking sockets, then you just read until the buffer is empty. But even that would not make sense as sometimes packets are sent in several chunks, so how do you determine how to put these together (before decompressing).
--w00t-- is offline   Reply With Quote
Old 01-14-2008, 09:22 AM   #5 (permalink)
Forum Expert
 
TheOutkastDev's Avatar
 
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,933
Default

all packets should be in the format of

byte packetID
short Length
byte[] contents
TheOutkastDev is offline   Reply With Quote
Old 01-15-2008, 04:57 PM   #6 (permalink)
Account Terminated
 
Join Date: Dec 2007
Posts: 28
Default

Yeah but those seem different for some reason. i did notice when I look at the char list packet there is a 5 byte zipped packet followed by another packet. Wonder if there's always a 5 byte packet first, maybe that contains the size. So I uncompress it individually. I'll have to play around some more.
--w00t-- is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5