Developers.Gnutella.Handshaking

From Shareaza Wiki
Revision as of 20:09, 20 June 2009 by Kevogod (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Handshaking

There are 3 groups of headers in a handshake.


Each line normally starts a new header, unless it begins with a space or an horizontal tab

So, to make sure you have an entire header, you can't just parse for the \r\n, you have to make sure the line after that doesn't start wiht a space or tab.


Multiple header lines with the same field name are identical to one header line

This makes it more complicated also. It's possible to run into the same header twice. All the values listed in both are valid.


the client (server) SHOULD disconnect if receiving any response other than "200" at step 4

There are only 2 status codes commonly in use for Gnutella: 200 and 503. 200 means everything is fine, and 503 means there is a reason the connection cannot be made.


servents SHOULD use the standard "User-Agent" header rather than make up a "Servent-Vendor" header. However, it is perfectly legal to add new headers (e.g., "Query-Routing") when no appropriate HTTP header exists, as long as they follow HTTP syntax. Headers unknown to the servent MUST be ignored

So, some of the headers in a Gnutella handshake will be HTTP headers, while others will be made up for Gnutella.


Each item in the X-Try header gives the IP address of a servent and its listening port number. This is sometimes referred to as being a "connection pong".

In the language of Gnutella, a pong is a new remote computer telling us it's running Gnutella and we can connect. So, both pong packets and X-Try headers are pongs.