Re: Establishing a p2p connection in python

From: gs (gs.lists_at_gmail.com)
Date: 10/11/04


Date: 11 Oct 2004 07:55:58 -0700

Ville Vainio <ville@spammers.com> wrote in message news:<du71xg9f9vn.fsf@lehtori.cc.tut.fi>...
> >>>>> "gs" == gs <gs.lists@gmail.com> writes:
>
> gs> Proposed solution: I thought that one approach could be to
> gs> write a small server for my public server with the sole
> gs> purpose of keeping track of connected users and establishing
> gs> p2p connections on demand.
>
> One lightweight approach (assuming that a web server is available)
> would be to put up a cgi script that adds the ip:port information to
> onlineusers.txt. Then the clients can just use urllib to notify the
> script when they become online, and also get the list of connected
> clients by just retrieving onlineusers.txt. Of course onlineusers.txt
> could contain the lists of shared files for each client as well...
>
> If you use unique user ids, you can keep the file from growing up too
> much. If not, you could clean up dead clients by trying to connect all
> the specified addresses.
>
> gs> 1) I've written a threaded server that stores information
> gs> about connected servers in a "container class". This class
> gs> h

olds information about username, a unique ID, the connecting
> gs> adress and the actual socket. I have not been able to find any
> gs> information online on how i could go about to connect two
> gs> sockets. It would seem like the socket is already "occupied"
> gs> since it is connected to the server. Could one duplicate, or
> gs> otherwise get a dedicated socket for sending binary data, to
> gs> one connected socket from another? A few pointers and/or tips
> gs> would be greatly appreciated!
>
> If you went on to "connect" the two sockets, you would just
> instantiate a thread that forwards the data, and would use more server
> bandwidth than an FTP server would have used.
>
> The idea in p2p is to make clients connect to each other. The task of
> the server is to tell the clients about other clients so they can
> connect to each other.
>
>
> gs> 2) I've also failed to find python specific information on how
> gs> abouts one would do file resuming. I would think that you,
> gs> somehow, use md5-checksums to check file status and somehow
> gs> skip the first part of the datastream. Also, pointers and
> gs> maybe an explanation in (short) pseudo-code would be much
> gs> appreciated.
>
> It's trivial since you are going to implement a custom protocol
> anyway. Make the "get file" command that you pass to the file provider
> such that in addition to the file name you pass the starting offset
> within the file.
>
>
> gs> 3) Is this too big of a project for a novice programmer such
> gs> as myself? I do want to go through with this since it's a
> gs> genuine problem, but i do not know if i'm ready. I'm not a
> gs> "quitter" per say, but i'm afraid doing something TOO advanced
> gs> in the beginning might be overwhelming :)
>
> No, it's a great first project. Go ahead, I believe you will find it
> surprisingly easy, educational and something for which Python is a
> perfect fit.
>
> It'll be a fun project to expand as well, to provide chunked file
> transfer etc. You could also explore the alternative of making it a
> bunch of wrapper scripts that just invoke bittorrent...

Thanks all of you for the nice feedback. I'm spending all of my
sparetime just reading up on all technlogies and suggestions! :)

cheers,
gs



Relevant Pages

  • Re: MsgCommunicator v.2.00: Instant Messenger SDK, now with databases support
    ... expect persistent connections. ... they will wait for the server to pick them up. ... your Clients can stay "off-line" for about 30 minutes before they have to ... requests *simultaneously*. ...
    (borland.public.delphi.thirdpartytools.general)
  • sockets, closing and TIME_WAIT
    ... During heavy load the server can't follow anymore because the sockets ... my server should be able to handle 10 clients connecting ... This gets a free position in the array of connections, ...
    (comp.unix.programmer)
  • Re: TCP/IP redundant connections
    ... The clients have persistent TCP connections to the server, ...
    (freebsd-hackers)
  • Re: Intermittent Network Connections
    ... I've just reconnected the Server LAN nic 1 to the ethernet switch (the same ... Server IP config and Client IP config attached. ... > turn is connected to an ADSL modem out to the internet The clients connect to ... >> Clients can sucessfully log in but periodically loose their connections. ...
    (microsoft.public.windows.server.sbs)
  • Intermittent intra-LAN connectivity
    ... other desktops and their server produces strange ... The clients cannot get files ... Replaced all hubs with switches. ... connections for all interfaces and was rebooted. ...
    (microsoft.public.win2000.networking)