Search code examples
pythontwisted

Writing a P2P chat application in Python


Is it possible to write a peer-to-peer chat application in Python?

I am thinking of this from a hobbyist project point-of-view. Can two machines connect to each other directly without involving a server? I have always wondered this, but never actually seen it implemented anywhere so I am thinking there must be a catch somewhere.

PS: I intend to learn Twisted, so if that is involved, it would be an added advantage!


Solution

  • Yes. You can do this pretty easily with Twisted. Just have one of the peers act like a server and the other one act like a client. In fact, the twisted tutorial will get you most of the way there.

    The only problem you're likely to run into is firewalls. Most people run their home machines behind SNAT routers, which make it tougher to connect directly to them from outside. You can get around it with port forwarding though.