[bittorrent] Interactive client design

Nikitas Liogkas nikitas at CS.UCLA.EDU
Sun Apr 1 12:50:13 EDT 2007


I'd suggest taking a look at the event-driven programming paradigm. 
This is a good starting point: 
http://www.linuxjournal.com/article/7871

nikitas


----- Original Message ----- 
From: "Ryan Walklin" <ryanwalklin at gmail.com>
To: <bittorrent at lists.ibiblio.org>
Sent: Sunday, April 01, 2007 7:03 AM
Subject: [bittorrent] Interactive client design


> Hi All,
>
> I'm currently beginning a Mac Bittorrent client based on the libbt 
> engine (
> libbt.sourceforge.net), and had a high-level design question I'd 
> appreciate
> some comment on.
>
> I'm basing the logic for the application on the btget sample code 
> included
> with the library, which runs by accepting torrents from the command 
> line,
> parsing out the metadata, setting up a context to store the 
> application's
> state, contacting the trackers etc, all the usual stuff, then hands 
> control
> to an infinite loop which cycles through incoming and outgoing 
> socket
> requests and processes them. This loop runs until interrupted by a 
> Ctrl-C,
> then the program runs some cleanup code and exits.
>
> This approach works really well for a non-interactive client, where 
> you set
> it up with some torrents and leave it alone, but not so well for an
> interactive GUI client which will need to interrupt the socket 
> processing to
> add and remove torrents, change filesets, transfer rates etc. From 
> my own
> reading the obvious answer would be to hand the network code off to 
> another
> thread, so that the GUI is not blocked. However, this is far from 
> simple for
> me to implement, as I have no prior thread experience, and can see 
> that it
> would be easy to create a non-thread-safe condition if both the 
> network
> thread and GUI were accessing the thread at once.
>
> I would appreciate it if anyone could suggest an alternate approach 
> which
> avoided threads, or some guidance as to how to avoid non-thread-safe 
> code if
> threads are the best solution.
>
> The project is available at niagara.sourceforge.net.
>
> Kind Regards,
>
> Ryan Walklin
>


--------------------------------------------------------------------------------


> _______________________________________________
> BitTorrent mailing list
> BitTorrent at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/bittorrent
> 




More information about the BitTorrent mailing list