Jump to content

Very simple P2P messenger


Recommended Posts


I've been pretty silent in the last 2-3 years here in the forums, so I decided to put a script up I wrote some time ago.

This is a Peer2Peer messenger. Nothing fancy (e.g. no encryption), but it shows how to handle multiple tcp connections, for those that need an example for it - and I couldn't see another messenger on the forum that was posted with source code. But I have not done a thorough search on this, so I may have overlooked one.

As this is a P2P mesenger it does not need a server, but you can just keep it running on one computer to "simulate" a server that the others can connect to.

It's also unsuitable for more than a couple of persons, because every messenger connects to EVERY other running instance. And there's a hard limit ($MaxConnections) of 15 connections currently. The PING and PONG functions are currently not used... there's something wrong with my implementation.

Details about the protocol used to connect two Instances can be found in protocols.txt.

Every Instance broadcasts its own connections to all other peers on a regular interval, so only use this in an environment where you don't have to care about security.

After starting it for the first time, you need to go to the Login-Tab and decide on your nick and on a network name, then make sure to press the Apply-button! Next go to the People-Tab and select Connect. Then you need to enter the IP of another Computer running the messenger. The basic idea is: You enter the IP of one computer running the messenger and it will automatically connect to all others, too.

The messenger will check all incoming connections to see if they contain the same network name on the Login-Tab - if not, the connection will fail.

I am slowly working on this and use this with a few colleagues. It's still very simple, so if you dont need much, you may be able to use it right away. Or you can use it as a starting point for your own messenger or to get some ideas.

Anyway, if you got any questions, just post here or send me a message.


Edited by sugi
Link to comment
Share on other sites

Well, it's unencrypted, so it's only suitable for a network you trust. The Internet is not a network you should trust...

Also, as the connected peers' IP are broadcasted to all others, this means that if two people are behind a NAT and are connecting to a third, the third person will have problems. But as long as all people are behind their own NAT it may actually work. I've never tested it in that way and will probably never test it.

Basic rule: If all people can see eachother by the same IPs, there should not be a problem.

I wrote it as in our company we do not have any chat available and any form of chat that leaves the companies network (ICQ, MSN, whatever) is considered a security threat and is forbidden. Since my messenger does not send anything out of the network, I can use it without violating any rules.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...