Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,719 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,317 people online right now. Registration is fast and FREE... Join Now!




Seamless Downloading

 
Reply to this topicStart new topic

Seamless Downloading

BetaWar
post 7 Oct, 2008 - 07:27 PM
Post #1


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,976



Thanked 77 times

Dream Kudos: 1175
My Contributions


Well, this project idea was spurred by the last tutorial I wrote Linky that was the basics of talking together between Flash and Python via sockets.

At this point my idea is fairly simple, allow people to download and install the python server script and from that point onward download files in the background (without having a window open while the download is taking place, unless chosen by the user) then have a notification (maybe) appear in the bottom right/left of the screen when the file has been downloaded and nothing more than that. It seems like it would be a LOT less obtrusive than having a TON of opopup windows open saying you are downlaoding something (with IE) or the popup window open telling you and the whole world every file you are downlaoding at the time (FF), plus, because it will likely be written in Pythonwith wxPython for GUI it will be fully cross platform (as long as the people wanting to use it have downloaded the python stuff), making it open for most everyone.

Obviously security measures will need to be taken (such as adding/ creating a list of "trusted sites" which you can download from without a prompt (popup asking if it is okay to download from said site), and other things to try and minimize the security risks that this poses, as there are some).

If anyone would like to help out with this and everything that would be cool, I will probably be uploading my code for the server along the way with a link to the Flash client so you can see what it looke like, and how it is working. I plan on creating a nice PDF of documentation on the abilities and restrictions of the final product after it is completed, but as school can get in the way it may take a little while.

So, ya, what does everyone think about this?
User is offlineProfile CardPM

Go to the top of the page

abgorn
post 8 Oct, 2008 - 12:11 PM
Post #2


Hello Crap for Brains

Group Icon
Joined: 5 Jun, 2008
Posts: 851



Thanked 4 times

Dream Kudos: 25
My Contributions


Doesn't utorrents have this? But I still thinks it's a great idea but I think you should be able to set a specific download rate that would be the maximum so (unlike uTorrent) if your downloading large amounts of files at the same time, it won't slow down your computer and be "seemless".
User is online!Profile CardPM

Go to the top of the page

BetaWar
post 8 Oct, 2008 - 02:16 PM
Post #3


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,976



Thanked 77 times

Dream Kudos: 1175
My Contributions


Hm, I didn't know that uTorrent had something like this already, I may have to check that out and see how close it is to what I am thinking of doing.

I was thinking of allowing the user to specify th emax number of files they want to allow to be downloaded at a time, and maybe also monitor CPU usage, and if that goes over a certain % start pausing some downloads until it gets back to a reasonable amount used.
User is offlineProfile CardPM

Go to the top of the page

William_Wilson
post 8 Oct, 2008 - 02:24 PM
Post #4


lost in compilation

Group Icon
Joined: 23 Dec, 2005
Posts: 3,951



Thanked 13 times

Dream Kudos: 3275

Expert In: Java, C, Javascript

My Contributions


they have the max download and max number of files. The CPU usage is an interesting idea, but is that really necessary? With today's processors p2p programs take very little power. The only reason they didn't exist sooner is because of lack of CPU speed.

Making all of it picked by the user may defeat the purpose if the user doesn't know what "reasonable" values are. You will need to implement defaults which will suit these unknowing users as well.
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 11 Oct, 2008 - 09:25 AM
Post #5


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,976



Thanked 77 times

Dream Kudos: 1175
My Contributions


Okay, I have had some time to work on this and I think that I have the multi-threading working. If someone wants to take a look at this code to make sure I am thinking sanely that would be great. NOTE - This is the current code I have for the "server" which is run from the client's computer.

CODE
import Queue
import socket
import threading

policyTxt = "<?xml version=\"1.0\"?><cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"2727\" /></cross-domain-policy>\0"
class ClientThread(threading.Thread):
   def run(self):
      while True:
         client = clientPool.get()
         if client != None:
            print 'Received connection:', client[1][0]
            while True:
                message = client[0].recv(1024)
                if message:
                    print message
                    if message != "<policy-file-request/>\0":
                        reply = "ECHO: "+ message
                        client[0].send(reply)
                if message == "<policy-file-request/>\0":
                    client[0].send(policyTxt)
                if message == "<close-connection/>\0":
                    print "Connection closed: ", client[1]
                    client[0].close();
                    break;

clientPool = Queue.Queue(0)

for x in xrange(2):
   ClientThread().start()

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('', 2727))
server.listen(5)

while True:
   clientPool.put(server.accept())


If you want to see how it works so far here is a link to the client application (the flash front-end)
http://reigninggames.com/tests/flash/socks/basics_01.html

Instructions on how to run it:
1. Make sure that you have python installed on your computer
2. Create a new file (using notepad, or whatever) that you copy and paste the code above to.
2a. Save this file as a .py file (if you try .pyw it won't show anything)
3. Make sure your firewall is configured to allow python to communicate and access the internet (otherwise this will probably not work)
4. Run the python file
5. Click on the link above and see how it works
5a. NOTE - You will need to have the python file running otherwise the connection will fail.
5b. The policyTxt variable should not be touched. This is what is allowing the Flash to connect to your computer.

Usage:
At this point in time the usage is very simple. You can type things into the textbox at the bottom of the flash app and then click the send msg button and it will send the message to the server (client computer), which will print out the text and send a reply which is this:
ECHO: <user-entered-text>
The flash is configured to output everything that it recieves from the server like so:
Recieved: <server-text>

Commands:
At this point the commands that I have enabled in the server are simply as follows:
<close-connection/> - Tells the server to close the socket connection.

NOTE - Commands have to be sent to the server via the Flash. They can't be directly input to the server.

Tell me what you think.
User is offlineProfile CardPM

Go to the top of the page

dwayne
post 13 Oct, 2008 - 04:59 PM
Post #6


New D.I.C Head

*
Joined: 2 Aug, 2008
Posts: 39


My Contributions


Overall good idea. I personally don't know Python, at all. I stick to C++ and the occasionally have a bit of fun with what I know of C#.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 10:03AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month