Here's a very nice Gnutella program one in C - you should easily get samples there:
-
gtk-gnutella - The Graphical Unix Gnutella Client
Also there's Shareaza in C++, but that one's a multinetwork and the last time I checked its Gnutella implementation wasn't that advanced (bad track record) and it's Windows only:
-
Shareaza - Bringing P2P Together
Did you already read
Gnutella for Users - Gnufu and
GDF - LimeWire ?