Gnutella Forums  

Go Back   Gnutella Forums > Current Gnutella Client Forums > GnucDNA Based Clients > Gnucleus (Windows)
Register FAQ The Twelve Commandments Members List Calendar Arcade Find the Best VPN Today's Posts

Gnucleus (Windows) For assistance for users with the Gnucleus program. Important links: Updated Gnucleus 2.2.0.0 Installer! and also Updated Connection Caches for Gnucleus!


Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old March 1st, 2002
Gnucleus Developer
 
Join Date: May 29th, 2001
Location: Boston, MA
Posts: 110
swabby is flying high
Default

Open the Gnucleus.cpp file, if you look in the initialize funtion you'll see that there are two lines.

m_pDoc = new CGnucleusDoc(this);
CFrameMain* pMainFrame = new CFrameMain(m_pDoc);

Both CGnucleusDoc and CFrameMain are created and referenced from CGnucleus which is the root node because it is the first class to be run on start up.

The structure represents the fold down on gnucleus, CGnucleus is created, CGnucleus creates CGnucleusDoc and CFrameMain, CGnucleusDoc creates CGnuControl and all the other important data type classes like preferences, chat, sharing, and the cache. When CFrameMain is initialized it creates things like the window, the toolbar, the menu and it also is in charge of creating new windows, we call this the view.

Its called document/view architechture, the data of a program and all the processing to the data is in the document, which is seperate from the view which simply displays the data.

Step throuh the constructors of the program and you can see this, the program is nicely laid out, and the structure picture is a great help in getting from point a in the code to point b.

Thanks for the questions, I like going through the code and verifying things. Thanks too for the typo fix, once I install visio again I'll make sure I change that and update the page. I just put up a screenshots section last night, check it out.
Reply With Quote
  #12 (permalink)  
Old March 1st, 2002
Moak's Avatar
Guest
 
Join Date: September 7th, 2001
Location: Europe
Posts: 816
Moak is flying high
Default

Ah, I had an older version of your code again (using CVS now).

Now you create the CGnuControll object in CGnucleusDoc, but the timer function for CGnuControll are still feed via CFrameMain (m_pComm = m_pDoc->m_pComm)...

About nice layout, well, in this particular case you might want encapsulate the timer for the network functions into the network class. For exmaple SetTimer() is a Win32 API functions that allows callback too, then you don't need to send a WM_TIMER via the viewport and the whole way down to a subclass. When using a MFC wrapper, CWnd::SetTimer allows callback too.

Greets, Moak

Last edited by Moak; March 1st, 2002 at 12:27 PM.
Reply With Quote
  #13 (permalink)  
Old March 1st, 2002
Gnucleus Developer
 
Join Date: May 29th, 2001
Location: Boston, MA
Posts: 110
swabby is flying high
Default

The Timer in CFrameMain is a global timer, it handles all the sockets, chat, cleaning of old memory, everything. It is centrallized like this so that accurate statistics can be made on the status of gnucleus.
Reply With Quote
  #14 (permalink)  
Old March 1st, 2002
Moak's Avatar
Guest
 
Join Date: September 7th, 2001
Location: Europe
Posts: 816
Moak is flying high
Default

Perhaps you want to show those dependencies also in the 'structure'? I prefer no crossover dependencies, however, it's your code... see it as a suggestion. I just found this when looking into your code about network timers. Then I reported what was irritating in my eyes.

Have a nice weekend, Moak
Reply With Quote
  #15 (permalink)  
Old March 1st, 2002
Gnucleus Developer
 
Join Date: May 29th, 2001
Location: Boston, MA
Posts: 110
swabby is flying high
Default

The stucture represents what creates what, because if you want to access say a download that is going from the transfer window, you would look at the stucture and say, 'ok first i have to get a pointer to the frame, that will give me a pointer to the root, from the root i can get to the document, from the document i can get to the socket controller (cgnucontrol) and from there the download socket list.

There are many many interactions between classes, and thats because its a normal application and class interaction is normal.

Have a nice weekend also, sooo much code to write...
Reply With Quote
  #16 (permalink)  
Old March 1st, 2002
Moak's Avatar
Guest
 
Join Date: September 7th, 2001
Location: Europe
Posts: 816
Moak is flying high
Default SetTimer() vs timeSetEvent()

PS: I did finally decide to avoid SetTimer in my project, since I don't have a viewport/window handle in my later network class (designed to work in a DLL) and also WM_TIMER message has some bottlenecks. If you're interested read http://www.codeproject.com/system/simpletime.asp - especially the last part in the "WM_TIMER" paragraph. I think I will use an own worker thread inside the server network class (or a multimedia timer with timeSetEvent()), this can also handle notifies for finished DNS resolution or friendly TCP disconnects.

Happy coding... Moak

PS: CGnuNod::m_nSecsAlive might be better a DWORD instead of an int, it's the same on standart MS Windows architectures, but you never know your target.

Last edited by Moak; March 3rd, 2002 at 08:56 PM.
Reply With Quote
  #17 (permalink)  
Old March 5th, 2002
Moak's Avatar
Guest
 
Join Date: September 7th, 2001
Location: Europe
Posts: 816
Moak is flying high
Default CriticalSection/Mutex

Hi again Swabby,
what I wonder... you use a mutex (e.g. CCriticalSection CGnuControl::m_NodeAccess) only on write access to your socket lists (adding/removing nodes), but not also on read access (broadcasting packets). I don't think that std::vector<> is thread safe. I did cross check with Mutella, and Max does use a Mutex on read and write access - which is what i do usually too.

I would expect unexpectable behaviours in Gnucleus - or did I overprotect my code?

Greets, Moak
Reply With Quote
  #18 (permalink)  
Old March 5th, 2002
Gnucleus Developer
 
Join Date: May 29th, 2001
Location: Boston, MA
Posts: 110
swabby is flying high
Default

Not sure, I'll look at it.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on Gnucleus sockets, STL Kaom Gnucleus (Windows) 2 August 20th, 2002 12:08 PM
Question about Socket error Unregistered Support: General 2 June 25th, 2002 03:21 PM
gnucleus.exe will now close Unregistered Gnucleus (Windows) 0 May 29th, 2002 12:26 AM
Should LimeWire close when I close the terminal window? Unregistered General Linux Support 4 September 19th, 2001 07:37 PM
socket error? Unregistered Gnotella (Windows) 1 July 15th, 2001 08:31 PM


All times are GMT -7. The time now is 03:16 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.