Gnutella Forums

Gnutella Forums (https://www.gnutellaforums.com/)
-   General Gnutella Development Discussion (https://www.gnutellaforums.com/general-gnutella-development-discussion/)
-   -   zlib inflate() never returns end of stream (https://www.gnutellaforums.com/general-gnutella-development-discussion/91084-zlib-inflate-never-returns-end-stream.html)

CathalG March 3rd, 2009 03:06 AM

zlib inflate() never returns end of stream
 
Hi,

I am trying to inflate a negotiated deflated Gnutella TCP connection.

The way I am going about this is the following:

e.g. direction = client to server:

1. Append packet to buffered stream.
2. pass stream to inflate()
3. if returns 0 (Z_OK) (successfully begun inflating but not finished), wait for next packet
4. else if returns Z_STREAM_END, pass inflated stream to function to parse Gnutella message(s). clean out buffer.

I have gone through numerous deflated TCP connections with this method, but inflate() only ever returns 0 (Z_OK).
Therefore I never reach the end of stream, even though this TCP connection is finished with a handshake. So I am never able to parse the Gnutella content. :bangh:

Am I going about this the correct way? If not, where am I going wrong? If I am, why do I never reach end of stream?

Any help would be appreciated.

Thanks :),

Cathal

arne_bab March 4th, 2009 12:33 AM

I assume that#s because there isn't an end of the stream: Gnutella servents keep using the same stream for more data.

Do you get valid messages when you pass parts of the inflated stream to the parser?

CathalG March 11th, 2009 04:48 AM

Thanks for your reply.

Yes; if I wait until the TCP connection is terminated, then pass the incomplete inflated stream to a handler function: it does produce valid messages.

My next question is: how can I continuously process these messages without having to wait until the end of the connection?

i.e. Currently, if I pass the stream to a handler function after x packets (for example), the next time I call inflate() with the stream beginning at packet(x+1), it returns Z_STREAM_ERROR.

I assume this return value will result in an invalid inflated stream.

I hope I have explained this clearly enough.

Thanks for your help.

arne_bab March 11th, 2009 05:11 AM

Quote:

Originally Posted by CathalG (Post 340140)
i.e. Currently, if I pass the stream to a handler function after x packets (for example), the next time I call inflate() with the stream beginning at packet(x+1), it returns Z_STREAM_ERROR.

Can you just send inflate() the whole stream again, including the already processed part, but only take packets you didn't yet see?

Best wishes,
Arne


All times are GMT -7. The time now is 11:53 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.