Re: Establishing a p2p connection in python

From: Darren Kirby (bulliver_at_badcomputer.no-ip.com)
Date: 10/08/04


To: python-list@python.org
Date: Fri, 8 Oct 2004 08:23:24 -0700


quoth the gs:
> Hi!
>
> This is my first time posting to a newsgroup so please be gentle to me
>
> :)
>
> Introduction to my problem:
>
> I'm studying at the university and a lot of friends and I use MSN to
> communicate. The problem is that MSN file sending/receiving
> capabilities are terribly slow and has no resume option. We're also on
> different subnets and can not access eachoters computers through smb
> shares, nor can we have local ftp-servers.
>
> My programming background:
>
> I've been taking a few classes in JAVA, enough to get familiar with
> sockets, threads and the most common sorting algortithms and
> datastructures (binary trees, stacks etc). I'm also very comfortable
> programming PHP on a webdeveloper basis.
> I recently started out with Python and i immediatly fell in love with
> it, and now I want to "master" it! :) Alas, my problem is also of
> educational nature.
>
> Setup:
> We're about 30 friends who want the ability to share files.
> We're spread out on about 3 different translated external IPs.
> I have access to a public IP that has the ability to run python (but
> not enough bandwith nor space to host an FTP).
> I have limited programming experience.
>
> Proposed solution:
> I thought that one approach could be to write a small server for my
> public server with the sole purpose of keeping track of connected
> users and establishing p2p connections on demand.
>
> Problems:
> 1) I've written a threaded server that stores information about
> connected servers in a "container class". This class holds information
> about username, a unique ID, the connecting adress and the actual
> socket. I have not been able to find any information online on how i
> could go about to connect two sockets. It would seem like the socket
> is already "occupied" since it is connected to the server. Could one
> duplicate, or otherwise get a dedicated socket for sending binary
> data, to one connected socket from another? A few pointers and/or tips
> would be greatly appreciated!
>
> 2) I've also failed to find python specific information on how abouts
> one would do file resuming. I would think that you, somehow, use
> md5-checksums to check file status and somehow skip the first part of
> the datastream. Also, pointers and maybe an explanation in (short)
> pseudo-code would be much appreciated.
>
> 3) Is this too big of a project for a novice programmer such as
> myself? I do want to go through with this since it's a genuine
> problem, but i do not know if i'm ready. I'm not a "quitter" per say,
> but i'm afraid doing something TOO advanced in the beginning might be
> overwhelming :)
>
> Thanks for reading,
> gs

I can suggest taking a look at nicotine, which is a full fledged p2p app
written in python. I'm not saying it's your solution, but you may get some
ideas about how to implement what you want by reading the source code, as it
does support file resuming.

-d

-- 
Part of the problem since 1976
http://badcomputer.no-ip.com
Get my public key from 
http://keyserver.linux.it/pks/lookup?op=index&search=bulliver
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972 




Relevant Pages

  • Establishing a p2p connection in python
    ... programming PHP on a webdeveloper basis. ... I thought that one approach could be to write a small server for my ... users and establishing p2p connections on demand. ... It would seem like the socket ...
    (comp.lang.python)
  • Re: killing thread after timeout
    ... >> I am going to write python script which will read python>> command from socket, run it and return some values back to>> socket. ... The child processes can acceptincomming connections on its copy of the socket. ... and pipe the data to and from worker processes. ...
    (comp.lang.python)
  • Threading problem when many sockets open
    ... I have written a socket based service in python and under fairly heavy ... enqueues the connection on a Queue. ... connections do not pile up very quickly. ...
    (comp.lang.python)
  • Socket programming design problem
    ... After programming with Python for a few hours, I've come up with some code: ... non-blocking ones?) ... I mistyped something and Python ... However, the socket does not seem to be cleaned up properly, as if I try to ...
    (comp.lang.python)
  • Re: Check if socket is still open?
    ... >>When the remote has closed the TCP session (or the TCP session times ... Then you can close the socket and go on. ... Programming with connections, or sockets is absolutely ...
    (comp.unix.programmer)