(Version 0.21, Author: Mark "Moak" Seuffert, Editing: Wanted, my english is crappy)
Hi programmers, coders, geeks and geekgirls! Maybe you ask: "How can I build my own client? Where do I start?". Then this article is for you, it's intended for new programmers and gives a short overview on Gnutella programming. First of all, understand how Gnutella works. Pictures say more than words, here are two sweet network animations:
http://www.milkdrinker.com/GnutellaToadHow4.swf (note: Flash Plugin required)
http://www.limewire.com/gnutella_flash.html
For more background visit the web, there are many articles about peer-to-peer networking available [1] [2].
First steps
I'd recommend to test some existing clients first, have a look on more than one Gnutella client [3]. Investigate how they work, check out features, GUI, usability, stability, which advantages they bring or what you dislike. Probably you already collected some ideas of what you would like to improve.
If you are NOT a programmer, (learn to become one or) visit a specific client forum and tell other users about your ideas [5]. Usually feedback is highly appreciated and helpfull for further improvement or killing nasty little bugs. If you are a coder, good, then just download some source code of existing servents or browse online [6] [7]. There is source code avilable on different operating system (Linux, Windows, Mac) and for different programming languages (C++, Delphi, Java, Perl, VB, etc). Two reasons why you should take a look inside allready existing code:
1. Do not reinvent the wheel (without serious reason).
2. Propably you find a suitable project and can work within a nice team.
Of course it's also a good idea to compare Gnutella clients with other filesharing systems like FastTrack, eDonkey and Freenet [4]... be inspired and combine the best ideas and technologies.
Building your own servent
Decided to start coding your own Gnutella servent? Yeah, creating a new Gnutella client is perfect for understanding Gnutella details, a great education project about networking or just for having fun in your free time. Grab a good complier (free compilers and development environments are available for every OS), buy some Coke or whatever is your favorite caffeine/beverage and be prepared to hack some nights.
The first thing you should put your focus on is a stable and efficient networking core. Make sure you really understand what you do. Learn to work with a local network (LAN), IPs, ports, routing amd tools as 'ping, telnet and netstat'. If these things are new to you, a simple client/server communication program will be a perfect test environment and playground. Ask Google or MSDN (Microsoft Developer Network) for: 'Berkeley Sockets' or 'Winsock'. When being familiar with those networking basics, you could either learn from existing open source Gnutella software (learn don't steal) - or directly start your own servent.
The word 'servent' means 'server' and 'client' at one time, because a Gnutella program will always offer files for download (a server) and at the same time it will be used to download files (a client). If you have decided for a network/thread concept then implement
Gnutella protocoll 0.4 features [8] step by step. Start with connection handshaking (quite easy) and then implement
Ping/Pong [9], defenitely some work and many hours of coding. For a testing environment you simply run two of your own servents on different ports (e.g 6346 and 6347). You can test everything offline on your own PC or LAN. As next step implement more protocoll features. After you did implement
host cache querying [10], you can finally test online and check your compatibility with more others servents.
We are coming to a important point... you wanna see action, have fast multisegmented/swarmed downloads, automatic resume and researches, right? Whatever your further steps will be, make sure your basic Gnutella core runs well and your concept works! Propably write smaller test programs to play & learn. If you think your concept will not fit later needs, start over! Having a good object oriented concept will save you from wasting a lot of time later (e.g. strictly split operativ code from GUI, break code into smaller independent parts). One large request for the sake of Gnutella: Please test your client + make it healthy for the network!! Other developers will be lucky to help and share experience. Perhaps you will also find more people to work together in a team, just ask.
Do you have questions about programming, networking, Linux, WinAPI, protocol implementations... or want to give some feedback about your work? Let us know, e.g. on Gnutellaforum's Developer Forum (right here) [11] or Yahoo's Developer Forum (GDF) [12]. More documentation and links will be available there. Feel free to contribute with your ideas and knowledge.
Thx for reading and have a lot of fun, Moak
"
For if a thing is not diminished by being shared with others,
it is not rightly owned if it is only owned and not shared" - Aurelius Augustinus
Before I forget: There is a damn good written article about "Being a better programmer" [13]. It's about game programming, but held very generall and highly recommended!
[1] What is Gnutella? -
http://gnutellanews.com/information/...gnutella.shtml
[2] Understanding Peer-to-Peer Networking -
http://www.limewire.com/index.jsp/p2p
[3] Gnutella Clients -
http://www.gnutelliums.com/
[4] Zeropaid -
http://www.zeropaid.com/
[5] Gnutellaforums -
http://gnutellaforums.com/
[6] Gnutelladev -
http://www.gnutelladev.com/source.html
[7] Gnutella on Sourceforge -
http://sourceforge.net/search/?words=gnutella
[8] Gnutella protocol v0.4 rev 1.2 -
http://www.clip2.com/GnutellaProtocol04.pdf
[9] Ping Pong -
http://gnutellaforums.com/showthread...&threadid=5213
[10] Host Caches -
http://gnutellaforums.com/showthread...&threadid=5807
[11] Gnutella Development Discussion -
http://gnutellaforums.com/forumdispl...?s=&forumid=42
[12] The Gnutella Developer Forum (GDF) -
http://groups.yahoo.com/group/the_gdf/
[13] Being a better programmer -
http://www.flipcode.com/tutorials/tu...ogrammer.shtml
Thx to Morgwen, Efield, Cyclocide