Can someone give a code snippet on how to 'chat' using the XMLRPC library in Python? Here's my server code:

from xmlrpc.server import SimpleXMLRPCServer
from xmlrpc.server import SimpleXMLRPCRequestHandler
import os
from os import access, path

PATH = 'chatlog.$'

class RequestHandler(SimpleXMLRPCRequestHandler):
    rpc_paths = ('/RPC2',)

server = SimpleXMLRPCServer(("localhost", 8000),
                            requestHandler=RequestHandler)
server.register_introspection_functions()
server.register_function(pow)

def chat_function(self):
    return (self)
server.register_function(chat_function, 'chat')

def chat_store(self):
    to_write = self
    if path.exists(PATH):
        chat_st2 = open(PATH,'w')
        history = chat_st2
        chat_st2.seek(0)
        chat_st2.write(str(to_write))
        chat_st2.close()
        chat_st2 = open(PATH,'r')
        print (chat_st2)
    else:
        open(PATH,'w')
        chat_st2 = open(PATH,'w')
        chat_st2.write(str(to_write))
        chat_st2.close()
server.register_function(chat_store, 'store')

print ('Starting your XMLRPC Server...')
print ('Press Ctrl+C to exit')
server.serve_forever()

if KeyboardInterrupt:
    exit()

But for some reason it keeps getting errors.

This project needs more than a badly put together code snippet. Learn about xmlrpclib first, by running the examples in the documentation. Your program needs a thread to start the xmlrpc server to receive the other side's messages and a user interface to forward your messages to xmlrpc calls and to display both sides messages. This interface could a simple terminal interface to start with.

Be a part of the DaniWeb community

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