Hi there,
I'm currently in the process of creating a Multi-User Dungeon (MUD) in python.
It'll allow multiple users to explore a text based world.

I've got a basic server but i can't seem to get a client to work with it.

MUD server.py

import socket

#Connect with telnet
#On linux: telnet localhost 5001
#or: telnet 5001 (if you connecting to a different machine)

#Port we wish to serve on

#create STREAMing socket (TCP)
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#Bind to any/default interface on the local machine
serversocket.bind(("", SERVER_PORT))

#become a server socket

#List of clients - fill this up as we go

#Each client has a name and a socket.
#You can/should add to this - location, inventory, ...

#Set blocking to OFF.  Without threads, this is the only way we can
#deal with multiple users.  If blocking is ON, we will be stuck at the
#accept() funciton call until someone connects

while True:
        #accept connections from outside. Note we get a new socket
        #object, leaving the original one free for more users to
        (clientsocket, address) = serversocket.accept()
        #add it to the client list
        person["name"]="guest" #Everyone starts as guest
        #Set blocking to OFF.  Same as before, but this time we don't
        #want to block on the recv() call
        #Non-blocking sockets throw an exception if asked to
        #connect/recieve when there's nothing to do.  They do this
        #rather than block.  We need to cope with that, so we catch
        #the exception and move on

    #Keep a list of messages ready to be sent

    #See which clients have something to say
    for c in clients:
            #Catch the exception associated with non-blocking sockets again
            if data!="" and data != None:
                #Use this if you need to debug exacty what the server receives from clients
                #for ch in data:
                #    print ord(ch),",",
                if data.startswith("say:"):
                    messages.append("%s says '%s'\n"%(c["name"], data[data.find(":")+1:]))
                elif data=="look":
                    c["sock"].send("I can't see anything.  Nobody has implemented locations.  Yet...\n")
                    #If there is something else, send a message back
                    c["sock"].send("Sorry, didn't understand that.\n")
    #Now we have a list of messages sent from clients since the last
    #time through the loop, we send each item to every client
    for c in clients:
        for m in messages:

an example of a client i'm trying to ge to work is:

#Send text to the log server

import socket

HOST = ''
SERVER_PORT = 5001              

serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

while 1:
    #Get any data
    data = raw_input("Data: ")

    if data=="quit": break

As i said i cannot get it to work, if i could the res, i think, would be a cakewalk (putting in rooms and equipment etc.)

Can anyone give me any advice to help get this working together?
I am abit stuck.

My apologese if i havent been very in depth.

Thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.