Okay, I wanna give a short overview on how to use a hostcache.
A
Gnutella Hostcache has a single purpose, it will feed you with a bunch of fresh IP-addresses from other Gnutella servants. We allready know that a gnutella servant (YOU) is connected to a few other servants (or to superpeers if available in future). While Gnutella works decentral your client needs a starting point:
1) Hostcaches provide fresh IPs and are a good starting point if you need to find more servants. Connect to an hostcache using the normal Gnutella protocoll [1], the host cache serve the single purpose of responding with pongs to your
ping, and disconnecting afterwards.
2) Many servants collect IPs of other servants while they are connected (from those they are connected or from received PONGs) and reuse them on startup.
Note to 1: Don't forget a hostcache will allway drop the connection after serving you the IPs (around 100 pongs usually, but I heared from a hostcache responding with 1000 pongs). There could be also a number of other reasons you are disconnected. Propably the servent is just busy now and can't handle more connections... or pinging you, but you aren't answering with a pong... or you don't share files (see your ping descriptor data) and disconnect because it doesn't help freeloaders. The best idea is to ask many hostcaches [2].
Btw, do not hardcode the gnutella hostcaches as IPs into your code (use hostnames here). Because IPs can change and a DNS resolution does not take a lot of time.... maybe you wanna add the current IP of your hostcaches into your hostslist (see next note).
Note to 2: Collecting IPs of other servants, especially of servants you have been allready connected with, gives you the advantage of a much faster gnutella startup (a few seconds)! Without such a list, you have to query every hostcache and try every IP until you are connected to some servants (or superpeer). Servants may be down or currently accepting no new connections... this try'n'connect could take up to two minutes. Think about collecting and storing IPs into a file (e.g. Xolox stores a few hundred IPs into a hostslist file).
Additional Links:
[1] Gnutella Protocoll
http://www.clip2.com/GnutellaProtocol04.pdf
[2] Host caches
http://www.gnutellaforums.com/showth...4638#post16845
Actually I'm not a client developer, these information are only as far as I found out from analyzing Xolox, Bearshare and reading various Gnutella articles. It would be nice if some developers of current clients could give us a feedback.
Hope it helps, Moak