Peer-to-Peer Chat Program

Trevor Slocum tslocum at gmail.com
Mon Aug 4 01:14:27 EDT 2008


Python seemed like the right choice for writing a peer-to-peer application,
as the support for sockets is adequate and the cross-platform ability is
nominal.  That's why I searched around for P2P frameworks in Python, and
didn't have much luck.  The framework that I did find was designed
specifically for file transfers, rather than simple message carriers, and
implemented a complex multicast system.

So, with Python in one hand and Google in the other, I set out to write my
own P2P app in Python, with zero previous P2P experience.  I had to start
off by looking up how P2P works, then figure out how to get messages across
the network, and then how to bootstrap each node, without centralizing the
network.

I decided to make it connectionless because they were simple messages.  The
current implementation is that a peer creates a message and forwards it to
all of its known peers, and then the other peers do the same.  This is for
simplicity, as it causes quite a bit of needless rebound from each of the
other peers sending a message which has already been received.  In order to
reduce this, each message is tagged with a unique ID which is verified
against upon each arrival.

Once that worked well, I needed to get peers to know each other.  My current
solution is a provider script running on a single server which is
auto-pinged every minute by each peer, and any new peers receive a list of
known peers from it.  This can easily be expanded to many more servers in
case any go offline.  Even if zero providers are online, users can manually
add nodes from the console and the framework will automatically build a
known peer list from them.

Like I said, I didn't know anything about P2P before this, and I'm sure much
of what I've done so far can be improved upon.  That's why I'm posting
here.  I'd like to make an open request to anyone who would like to assist
me in the application development to reduce the resource usage and improve
the overall network efficiency.  Even simple "Ah, I saw you were doing this
in your code, I recommend you do this..." would be of great help.

If you are interested, you may view the Google Code page at
http://code.google.com/p/kaishi/ or checkout the SVN repository directly
using http://kaishi.googlecode.com/svn/trunk/

I have proper hosting and can set up a specific website for collaboration on
project ideas and such if support is carried after this message.  I thank
anyone who has taken their time to read this.

-- 
Trevor "tj9991" Slocum
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080803/9440b968/attachment.html>


More information about the Python-list mailing list