(Image 1)
(Image 2)
(Image 3)
Introduction to an open source Gnutella client - Gnucleus
Gnucleus project is one of an open source Gnutella clients, in which NullSoft had originally created a P2P (peer-to-peer) application. However, AOL - the parent company of NullSoft, ordered NullSoft to shut down this project. In spite of this situation, many clones of Gnutella have been created, and many Gnutella client projects provide us the free source code.
Especially, Gnucleus is developed in Visual C++ and uses CAsyncSocket
class in MFC very well. I have downloaded Gnucleus 1.7.4.0 source code, but I haven't read these codes in detail that time. After I installed WinCVS, and updated to the latest Gnucleus 1.8.4.0 source code, I had my mind to share these source codes with other people interested in P2P applications as well as CAsyncSocket
.
Since Gnucleus is a huge project, I will not provide all tutorials to Gnuclues at one time. However, I found that Evolve dialog is the better and simpler example of how to use HTTP GET command and CAsyncSocket
class.
How Evolve Dialog works?
Evolve is the process to update the latest Gnucleus.exe file and the other files when we open Gunclues. Each Gnuclues has its own version number in the source code. update.xml includes the information of which files should be downloaded and updated. In order for Evolve process to work as a stand alone dialog application, I made some Doc, View derived classes and the other classes object line disabled. I want to keep source code as original as possible.
CInternetSession GnucleusNet
gets the information of which versions and files should be updated. CGnuEvolve* m_Download
actually posts HTTP GET command to the webserver to download each updated file.
- Choose which host is used to update the files? (Image 1)
Originally, Evolve dialog of Gnucleus doesn't have this message box, but I need this to make some tests for update.xml file at the local web server. This time, I don't want to distribute the files needed, so if you choose NO of this message box, you will get some error message. You can download the necessary files from here.
After you get the necessary files, you create update folder at the top directory of your local web server. And try to type http://localhost/update. If you view this directory as Gnucleus web server has, the local web server choice of this message box should work.
I just show the directory and files needed for the localhost to work.
/update/update.xml
/update/Gnucleus_1.8.4.0/Gnucleus.exe
/update/Gnucleus_1.8.4.0/GnuBlocked.net
/update/Gnucleus_1.8.4.0/ChangeLog.htm
/update/Gnucleus_1.7.5.0/WebCache.net
- Evolve Dialog detects the latest four files updated. (Image 2)
If we click Evolve button or wait about 15 seconds, Evolve dialog downloads the necessary files by HTTP GET command from the web server. CGunEvolve
objects keep the buffer from the downloaded files, and CFile
object adds these buffers to the files. Image 3 ListBox shows some process of what kinds of GET command are send to the webserver and how CAsyncSocket
functions like OnConnect
, OnSend
, OnReceive
, Send
, and Receive
are called.
This is an example of how these functions are called:
TRANSFER_CONNECTING
Creating Socket is success
Connecting to localhost is success.
Send is called.
TRANSFER_CONNECTED
GET /update/Gnucleus_1.8.4.0/GnuBlocked.net HTTP/1.1
User-Agent: Mozilla/4.0
Host: localhost:80
Connection: Keep-Alive
OnSend is called
TRANSFER_RECEIVING
ReadFile is called.
m_File.Write is called.
GnuBlocked.net Gnucleus_1.8.4.0/GnuBlocked.net Evolve
GnuBlocked.net Gnucleus_1.8.4.0/GnuBlocked.net Evolve
TRANSFER_CLOSED
Close() is called
OnRecieve is called.
TRANSFER_CONNECTING
TRANSFER_CLOSED
Close() is called
Last, this time, I didn't explain the code in detail partly because these codes come from Guncleus gurus. I appreciate for Gnucleus gurus for this free source code.
Visual C++ developer & Master of Business Administration (MBA) holder.
My interests moves from MFC to C#, especially ASP.NET, Web Service and Mobile Development.
I have lived in Atlanta, GA of USA from 1995.
As my name shows, I'm a Japanese.
This is my name in Japanese.
大西 正明
I have moved to NJ to work for the project to rebuild GUI (MFC) of some big Japanese electrioc company product. Sometimes, I enjoyed to walk around NYC.
(April 09, 2006 updated)
I have come back to Japan from August, 2004. Currently, I live in Tokyo in Japan, and work as a contract software engineer in the Japanese major securities company. The languages of the project are VC++(MFC) and VB.