Skip to content
A very simple client/server library for multiplayer python games
Branch: master
Clone or download
Ganapati Merge pull request #1 from josxha/master
Thx ! python 3 migration
Latest commit cbb698b Oct 1, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Dec 22, 2014
LICENSE Initial commit Dec 22, 2014 Update doc Jan 11, 2015 migrated to python 3 Oct 1, 2019 migrated to python 3 Oct 1, 2019 Add documentation to class Jan 3, 2015 migrated to python 3 Oct 1, 2019


A very simple client/server library for multiplayer python games

  • Handle multi-rooms
  • TCP for server actions
    • Register to server (get uniq identifier)
    • Create/join/leave room
    • List rooms and capacity (ex: room1 2/10 players)
    • Autojoin the first non-full room
  • UDP for broadcasting data to other players

Quickstart and demo

Launch on your server :

  • ./python --tcpport 1234 --udpport 1234 --capacity 3
    • --udpport udp port to listen
    • --tcpport tcp port to listen
    • --capacity maximum players per room

Launch :

  • the main method from client is a test-case with 3 clients instances. The first create a room, second and third join and start sending data.

How to add multiplayer in your games

Start server :

user@server >>> ./python --tcpport 1234 --udpport 1234 --capacity 10

In the client code :

Only add the file to your project

# Add Client instance to your game
client = Client("", 1234, 1234, 1235)

# Get room list (room_id, nb_players, capacity)
rooms = client.get_rooms()

# You can join a room using room identifier (ex: first room)

# You can autojoin the first available room client.autojoin()
# Or you can create a new room with client.create_room("room_name")

# In your game main loop
while game_is_running:
    # Data to send
    data = {"foo": "bar", "baz": "gu"}

    # Send data to all players in the room
    # Send data to one player in the room
    client.sendto(someone.identifier, data)

    # Send data to multiple players in room
    players_ids = [player1.identifier, player2.identifier]
    client.sendto(players_ids, data)

    # Read received messages
    messages = client.get_messages()
    if len(messages) != 0:
        for message in message:

Each received message is given with remote player identifier.

Server commands

  • list : list server rooms
  • room #id : show informations about room
  • user #id : show informations about player
  • quit : quit server
You can’t perform that action at this time.