5,445,109 members and growing! (14,317 online)
Email Password   helpLost your password?
General Programming » Internet / Network » Third-party libraries (free)     Intermediate

Gnucleus Tutorial (Part 1)

By Masaaki Onishi

Tutorial of Evolve Dialog of Gnucleus - Gnutella Client.
VC6, C++Windows, Win2K, MFC, VS6, Visual Studio, Dev

Posted: 26 Jul 2002
Updated: 26 Jul 2002
Views: 40,672
Bookmarked: 17 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
10 votes for this Article.
Popularity: 3.00 Rating: 3.00 out of 5
2 votes, 50.0%
1
0 votes, 0.0%
2
1 vote, 25.0%
3
0 votes, 0.0%
4
1 vote, 25.0%
5

(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.

  1. 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
  2. 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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Masaaki Onishi


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. Smile

(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.
Occupation: Web Developer
Location: Japan Japan

Other popular Internet / Network articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 2 of 2 (Total in Forum: 2) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralGnucleus in C#memberRussel Harvey19:01 5 Nov '02  
GeneralGnucleus web site seems to be down now?memberMasaaki Onishi7:06 28 Jul '02  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 26 Jul 2002
Editor: Smitha Vijayan
Copyright 2002 by Masaaki Onishi
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project