pygame is
Simple DirectMedia Layer is
Site Swing
Mastermind Networking Lib

Mastermind Networking Lib - 1.5.1

Ian Mallett (geometrian)



Mastermind is a networking lib designed to be easy to use and robust. The name comes from the goal of this project, which was to make a program which is covertly behind all networking, making things run nice and smoothly with little user input.

I made this library partially for fun, partially for pyweek, partially for utility, and partly so I would know more about networking. Networking is a lot harder than you would think, so I have spent a past week or so developing this library, which should make the tricky stuff automatically done behind the scenes.

Includes fully customizable output for server and client events.

See Docs.txt for help on making networked programs.


Tiny little fix which makes quitting easier (no stupid little quit flags to send).


Home Page:


click to view original size


Mastermind Networking Lib - 4.1.3 - Jun 29, 2013
Mastermind Networking Lib - 4.1.2 - Jan 2, 2013
Mastermind Networking Lib - 4.1.1 - Dec 27, 2012
Mastermind Networking Lib - 4.1.0 - Dec 27, 2012
Mastermind Networking Lib - 1.5.2 - Jan 17, 2009
Mastermind Networking Lib - 1.5.1 - Sep 1, 2008
Mastermind Networking Lib - 1.5.0 - Aug 30, 2008
Mastermind Networking Lib - 1.3.0 - Aug 24, 2008
Mastermind Networking Lib - 1.1.0 - Aug 22, 2008
Mastermind Networking Lib - 1.0.0 - Aug 22, 2008 account Comments

If you wish to leave a comment with your account, please sign in first.

June 29, 2013 8:07pm - Ian Mallett - nickname: (geometrian)
Version 4.1.3 released! This is a minor release that improves the examples.
January 2, 2013 11:16pm - Ian Mallett - nickname: (geometrian)
Version 4.1.2 released! This is a minor release fixing a few problems. Remote server example not set up yet.
December 27, 2012 8:23pm - Ian Mallett - nickname: (geometrian)
Version 4.1.1 released! This is a minor release fixing mostly syntactic errors. By next release, I hope to set up a remote server example to run for the forseeable future.
December 27, 2012 3:59am - Ian Mallett - nickname: (geometrian)
Version 4.1.0 released (versions 2.0.0, 3.0.0, and 4.0.0 were pre-release work, and were mostly false starts on the rewrite)!
October 1, 2012 7:03pm - Ian Mallett - nickname: (geometrian)
Most of the client and server code handles a GUI, which isn't important to understanding how to use Mastermind. You should see Docs.txt if you just want a simple example.
May 8, 2012 5:18pm - Gabriele - nickname: (g181)
this version(Mastermind Networking Lib - 1.5.2 - Jan 17, 2009) work very well for me but i don't understand the python code can you put in server and client file more comments???
Thanks its only two day tha i programm in pygame, i programm very well in python but i don't understand all... thanks a lot!!!! Maybe a video guid ;)
May 29, 2010 11:07am - Magnie Mozios - nickname: (magnie) - 3/5
This is pretty good, maybe make a feature to give the user the ip address of the sender.

def address(self,sock,host,port,address):return address

? I have little understanding in what you've coded in the file, so I wouldn't know how to make it myself :P
April 3, 2010 8:43am - Per F - nickname: (worldsayshi)
"my computers ip on the network" = the ip of the server computer
April 3, 2010 8:42am - Per F - nickname: (worldsayshi)
I made another try and made it work!

This is what I did (It might be obvious but it confused me). Connecting localhost only makes the server reachable on the same computer. So I switched "localhost" in both server and client to my computers ip on the network. This allowed me to connect from any computer in the network to my server.

I'm a network noob and confused about the meaning of 'localhost'. On my computer it was translated to an ip local to the computer itself (not an ip used on the LAN). This might not be standard though.
December 28, 2009 11:28am - Ian Mallett - nickname: (geometrian)
Hi, yes, pymike's server is presently down, so that wouldn't work. It should work immediately--the underlying sockets library seems to handle everything automatically (e.g., I did nothing special to wirelessly connect to a router linked to a DSL modem). You have to make sure you're connecting to a server (, or an IP). If the computer is on the same LAN, you should probably be using localhost.
December 8, 2009 5:37pm - Per F - nickname: (worldsayshi)
Oh, if the printout would puzzle you: I've replaced the "localhost" entry in the code with a variable that ables me to enter the host adress through raw_input.
December 8, 2009 5:34pm - Per F - nickname: (worldsayshi)
Looks very promising. But I can only make it work connecting to a localhost server. If I try to run the server on another computer in the network and try to connect to it or if I try pimike's server I get:

File "", line 17, in <module>
File "/home/perf/Skrivbord/Mastermind 1.5.2/Net/", line 123, in connect
raise SocketError("The connection could not be opened. It must be created first with a server object.")
Net.errors.SocketError: 'The connection could not be opened. It must be created first with a server object.'

Are there any configurations in the local network that should be done first? Should the router be configured? Ports be opened (not when running within the local network no?)?

I'm using the example client and server applications on version 1.5.2
October 26, 2009 2:35pm - Ian Mallett - nickname: (geometrian)
Make sure your webhost supports running Python. Then FTP to the server, and run your server file. I suggest contacting pymike, who knows more about it.
October 24, 2009 8:31am - Y Körber - nickname: (kazius) - 5/5
very good. It works fine for network, but how can i create a "local" server, where others can join through the internet?
June 19, 2009 10:18am - Mystex - nickname: (mystex)
This looks pretty promising :) Can't wait to download it!
May 12, 2009 1:19am - Ian Mallett - nickname: (geometrian)
You have to wait for it to contact the server. For example, in the client, a constant loop is set up (i.e., it sends, then checks every time around the loop in Update() for a response from the server. If it gets one, it copies the response to the chat, and sends again, completing the cycle). When a chat message is sent from the client, the server adds it to the chat. Notice how when other clients ask for a copy of the chat for the server, they'll get the new, updated version of the chat. It's best to ask me questions about my stuff at [email protected]
May 11, 2009 4:55pm - Milen Hristov - nickname: (int13)
ok, I figured it out and the examples run ok.

I'm trying to learn the concept of mastermind but can't get the client/server logic. Let's say we have two clients connected to a server. If using self.send_data(data) in to respond the client-sender, how can I send the same data to the other clients(not the client-sender)?
May 10, 2009 10:53pm - pymike - nickname: (pymike)
What's your Python version? It works in Python 2.5.
May 2, 2009 12:14pm - Milen Hristov - nickname: (int13)
I'm new to Python networking and I can't get the examples working:

./ line 3: syntax error near unexpected token `os.path.split'
'/ line 3: `sys.path.append(os.path.split(sys.path[0])[0])

January 17, 2009 11:55am - Ian Mallett - nickname: (geometrian)
Version 1.5.2 released!
There are presently no servers online.
January 10, 2009 7:14pm - Ian Mallett - nickname: (geometrian)
The new server is at:
Change the relevant line in to connect.
September 2, 2008 5:28pm - Marco Baxemyr - nickname: (phelerox)
This seems great, I'll definitely keep an eye on it. :)
September 1, 2008 12:21pm - Ian Mallett - nickname: (geometrian)
Actually, I've decided to rename this release 1.5.1 due to the tiny size of the fix.
September 1, 2008 12:14pm - Ian Mallett - nickname: (geometrian)
Version 1.6.0 released!
August 30, 2008 10:00pm - Ian Mallett - nickname: (geometrian)
Yes. Currently, just switch the commenting on lines 16 and 17 in The docs reiterate that too.
August 30, 2008 7:30pm - pymike - nickname: (pymike)
Lookin' good! The server is up on if you wanna see it working.
August 30, 2008 4:11pm - Ian Mallett - nickname: (geometrian)
Version 1.5.0 released!
August 30, 2008 2:09pm - Ian Mallett - nickname: (geometrian)
Definitely! Thanks for that.
I've isolated the problem (yes this version works, but not effectively enough for realtime client framerate thingies--a big caveat for games). I've been pretty busy lately, but I finally got something which should fix all of the problems. I completely reworked the function (so no guesswork) and the test seems to work with multiple clients. I'll be building it into the library later today ;)
August 29, 2008 2:05am - Robin Wellner - nickname: (gyvox)
The new version is great.

By the way, wouldn't it be easier to do this in "":
try:import cPickle
except:import pickle as cPickle
data = cPickle.dumps(Packet(data))

instead of:
try:import cPickle
except:import pickle
data = cPickle.dumps(Packet(data))
data = pickle.dumps(Packet(data))
data = str(len(data))+"||"+data
August 24, 2008 11:02pm - Ian Mallett - nickname: (geometrian)
Right ;)
August 24, 2008 9:45pm - pymike - nickname: (pymike)
Don't download this version... it has a bug. Ian's working it out ;-)
August 24, 2008 9:25pm - Ian Mallett - nickname: (geometrian)
Version 1.3.0 released! (Version 1.2.0 was pre-release work).
August 24, 2008 2:38am - Ian Mallett - nickname: (geometrian)
PyMike is referring to the next release of Mastermind, which should hopefully be coming soon. :-D

I'm pretty sure "Anonymous chatting" is meant as a shortcoming, in which case, you will be glad to know that it has indeed been fixed (small mod on the client). In addition, I've made the library about twice as fast (depending on implementation) due to my removing unneeded data transfer.

I'm presently working on making an example of a client which is independent of the server's update rate (i.e., a slow server does not equal a slow game), but have encountered delaying troubles with the unavoidable use of multiple sockets.
August 23, 2008 12:33pm - pymike - nickname: (pymike)
Hehe fun stuff :-D I think the latest version fixed that though :-D
August 22, 2008 5:06pm - Robin Wellner - nickname: (gyvox) - 5/5
Wow! Anonymous chatting!
August 22, 2008 4:39pm - Ian Mallett - nickname: (geometrian)
Thanks, PyMike!
August 22, 2008 4:39pm - Ian Mallett - nickname: (geometrian)
Version 1.1.0 released!
Fixes a minor bug, making the server more crash proof in online scenarios.
August 22, 2008 4:14pm - pymike - nickname: (pymike)
Very cool :)

For everyone else: The script is running on
If you want to connect to it, change line 7 in to:


If anyone abuses this then I'll have to take it down. It's only up for "proof that it works" ;-) Ciao!
August 22, 2008 3:54pm - Ian Mallett - nickname: (geometrian)
Version 1.0.0 released!

our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Feb 21, 2017

Jan 31, 2017

Jan 24, 2017

Jan 18, 2017

Jan 7, 2017

Dec 30, 2016

Dec 8, 2016

Nov 28, 2016

Nov 27, 2016

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)