December 17, 2009

MiniBoa

Over on Mudbytes, Idealiad (aka Kooneiform) started a thread about creating a Python Socket MUD -- a very tiny socket library that Python coders could use as the basis for their MUD projects and experiments. There already were a few of these for other languages such as TeensyMud for Ruby but nothing for Python. I really liked this idea and, as I had a working Telnet server already, I decided to repackage my network modules as MiniBoa. Instead of the BogBoa's GPL licensing, I switched to the more permissive Apache 2.0 (one of the recommended licenses for maximum compatibility with the Python's own).

To be honest, the code was a lot messier to convert into a stand-alone library than I expected -- because this was the first code I wrote for BogBoa and I was hooking into it less than gracefully. Since I didn't want to maintain two copies of (mostly) the same modules, I decided to revamp BogBoa to use MiniBoa for networking.

You can find code and documentation at the project page and some discussion on this Mudbytes thread.

6 comments:

amanita said...

Hello Good Sir!

After poking ugly C/C++ mud codebases with a stick for years, written by someone else two decade ago, that forced me to accept ideas that I never wanted to swallow. Every time opening C code in my editor I was about to stab myself with a knife... finally I found Miniboa!

MiniBoa is mind blowingly simple, this -IS- a *barebone* mud server. Exactly what I was looking for: python + single thread + non blocking + telnet.

Thanks!

amanita said...

MiniBoa MAX_CONNECTIONS on Windows XP SP3 32 bit.

I just tested miniboa chatdemo.py for max connections.

The method I used is: I have two pc-s connected with a router.

First PC running the miniboa server, on the other pc I open the cmd.exe and type in this bach script line:

FOR /L %X IN (1,1,10) DO (puttytel )

This line launch ten putty telnet client and login to chatdemo.py.

After a while I reached 510 connections on the client pc.

At this point I typed in manually one more connection and the server crashed around the poll() in async.py.

Fix: in async.py set max to 510 instead of 512.

if sys.platform == 'win32':
MAX_CONNECTIONS = 510

Running the test again it all went smoothly, after connection #509 adding one more caused no crash but the proper message: ?? 'Refusing new connection; maximum in use.'

amanita said...

if sys.platform == 'cygwin':
MAX_CONNECTIONS = 99

Yeah...

Jim said...

Thanks for the feedback, Amanita. I have done very little testing on Windows so this is helpful. I'll change MAX_CONNECTIONS to 500. At some point, I'd like to poll windows in two block of 500 each to support 1000 connections.

Can you elaborate on what fails under Cygwin?

amanita said...

Sorry cygwin max is around 72.
I have no idea what causes this, cygwin behaves odd when running the chat_demo sometimes.

I suggest everyone to use native python (like 2.7.1) msi installer on win32 to max out performance and avoid issues of the cygwin layer.

This is the error around connection #70-#73

Traceback (most recent call last):
File "./comm.py", line 220, in
telnet_server.poll() ## Send, Recv, and look fo r new connections
File "/cygdrive/c/fehernyul/fehernyul/async.py", line 13 9, in poll
self.timeout)
ValueError: filedescriptor out of range in select()

amanita said...

Oh the comment monster ate my post.

Again: cygwin uses up the windows file descriptors for posix stuff like pipes, sockets and other essential things.

ulimit -Hn says 3200, ulimit -Sn says 256! max opened files possible at a time in cygwin.

Btw cygwin is ok for testing only, if I want a server because my miniboa based text game is finished it will run on NetBSD (tests coming soon!) or Debian.

Imho even the most succesful commercial/free muds have some limits, maybe 2048 or whatnot? Who knows? There is no such a mud that have more than 300 players online at a time, ever. For a $ mud like Achaea from Iron Realms a 400 max would be enough, Aardwolf or Batmud never hit 500 ever.

Regards.