I am looking to start development on a game that will have the server be written in Python/PyGame and the front end be in HTML5. What I would like to do is, with as minimal impact as possible, open up a WebSocket or two to allow the server to push events to my browser.

Is this possible with Socket.IO, or do I need an extra layer to handle WebSockets? I'd like to avoid importing and installing extra packages if possible.


1 Answer 1


Socket.IO is a protocol, not necessarily completely driven by WebSocket. In fact, Socket.IO even has a Flash fallback in place because of this. You can use just the Socket.IO library and simply communicate with the game accordingly if you're okay with this. Python libraries that implement the protocol do exist, such as this one. However, just keep in mind this is not raw web sockets.

Not that this might be an issue for you, of course it is your choice to evaluate. Socket.IO is supported in JavaScript so you can communicate between Python land and Socket.IO land with no additional libraries if you please.

  • \$\begingroup\$ Honestly, its mostly because I quite like the Pythonic approach to programming and wanted to write my server-side code as completely in Python as possible. I'd been considering node.js, but I'd rather stick with Python. Really, I am just trying to get a feel if that persistent connection between server and browser is possible via a Python-based server script. \$\endgroup\$
    – erik
    Mar 27, 2014 at 0:50
  • \$\begingroup\$ There's no shame in that. :) I do the same but with a C# backend. \$\endgroup\$ Mar 27, 2014 at 18:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .