Cap'n Bry's gnutella search
Pretend to search for: Server timeout

Problems downloading?
The protocol
My clone
PHP source

Search stats

What's it all about?

Way back in the day, when gnutella first went into beta and then was quickly removed from production altogether, I set out to reverse- engineer the protocol so that development could continue on this webvolutionary concept. The fruits of that labor are sumarized in my protocol page. Not being one to just live in theory, I then set out to create a client.

I've created a TComponent-derived class in Delphi 5. The concept is that you can drop this component on your form, set some properties and event handlers, and bada-bing you've got fullon gnutellanet access in your application. The source code for this component is located below in the Downloads section of this document. This source requires Delphi 5 (any edition), as it uses Delphi's standard TServerSocket and TClientSocket and I don't think they had them working right in D4. Some people have requested that I convert the whole thing to use fpeitte's Internet Component Suite (ICS). Maybe I'll do that at some point, but I'm not really familiar with TWSocket and Delphi's sockets have been working well for me so far. Version 2. :)


  • gnutellatrans.pas - This is the Delphi (Object Pascal) source code for the component prettied up and put into HTML, just like it looks in the Delphi IDE. Pretty sweet eh?
  • Component and sample app - This ZIP file includes the component source, a pretty icon for your "Internet" component palette, and a sample application which shows how to hook up to component. See the Known Issues section below for a list of... well, known issues
  • Screenshots - A quick look at screenshots from the demo app.

Known Issues

  • Can't download files. This is done over HTTP so it's a snap to add it yourself.
  • No implemented buffering system for writing to clients who's winsock buffer is full (i.e. send() returns WSAEWOULDBLOCK). This means that you will drop data if you or the other side is congested.
  • On occasion, it just stops sending messages to other clients. It does a write on the socket but nothing comes out the other end.
  • The "gnutellaNet stats" are just plain screwed up. I haven't even looked at this yet.
  • The routing errors and dropped messages counts don't match up with a real gnutella client. I've gotta look closer at what to call what.
  • Doesn't do searching of your machine. I'll be implementing this in a plug-in architecture so I haven't worked out the details yet.
  • CPU utilization way too high. I haven't done a lick of optimization yet, but I know where the bottlenecks are. I'll probably do this last.


May 24, 2001 - New gnutellatrans.pas (in Fixed bug where I was htons()ing the port number I was sending in a init/ping response, Causing the querying gnutella to get confused about what port to connect on.

April 25, 2001 - New gnutellatrans.pas (in Why so long between updates here? Because I really don't have the time to work on it at all and the gnutella fad has come and gone I think. I only fixed two things in this version:

  • Major bug in the Routing Message List would cause an AV of you removed the last item in the list when purging a GConn. Was actually trying to ^.Next a nil pointer!
  • Added outgoing messages from us to the routing list. This means that incoming messages destined for us are acutally picked up by us! This fixed problems with the host catcher not working, search results not coming back, etc (anything where you're expecting a response from a message).

June 19, 2000 - New everything uploaded. Known issues fixed:

  • Changing your listening port with incoming connections would disconnect the clients, but not fire the event handler, leaving them in not-really-connected limbo. Fixed.
  • New Shutdown() function allows closing of all connections so no more events getting fired while in the destructor!
  • Attempting a Listen() of an already in use port no longer throws an exception. Thanks to Andreas Goetz for noticing that this wasn't being caught where I thought it was. (Guess I should actually try my code... not just write it)
  • Removed logging stream from test app.
  • Increased size of routing table to 8k nodes. This is what it was originally, but I lowered it to 128 for a test and forgot to put it back.

June 14, 2000 - Just uploaded a new gnutellatrans.pas and to the server. Added in this version is message routing (finally) and a merged list of outgoing and incoming clients. Fixes lots of bugs involving "Not a socket" errors when people disconnect.

Email CapnBry remove spam from the address for it to work
Home | Other things on linus
CapnBry's PHP Gnutella search v0.4 - See source code for licensing information