Simple RPC server and client
Posted: 11 Sep 2005, 12:00
Hi I am just playing around with code to see what I come up with
I came up with a server and client using XMLRPC
but I am having troubles I get an error when running the command from the client everything runs fine but when executing the function from the client I get an Error I have tried other simpler functions also like pow(x, y) I get the same error
anyway here is the code anyone who can help would be appreciated
cheers
Yes Python again all you java programmers must hate me
THe Server
And the client
and the error
Traceback (most recent call last):
File "<console>", line 1, in ?
File "F:\Python24\lib\xmlrpclib.py", line 1096, in __call__
return self.__send(self.__name, args)
File "F:\Python24\lib\xmlrpclib.py", line 1383, in __request
verbose=self.__verbose
File "F:\Python24\lib\xmlrpclib.py", line 1137, in request
headers
ProtocolError: <ProtocolError for localhost:8765/: -1 >
ANy Ideas cheers
I came up with a server and client using XMLRPC
but I am having troubles I get an error when running the command from the client everything runs fine but when executing the function from the client I get an Error I have tried other simpler functions also like pow(x, y) I get the same error
anyway here is the code anyone who can help would be appreciated
cheers
Yes Python again all you java programmers must hate me
THe Server
Code: Select all
import pygame
from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler
from SocketServer import ForkingMixIn
class Math:
def cdEject():
pygame.cdrom.init()
print "CDROM initialized: ", pygame.cdrom.get_init()
print "Number of CDROMs: ", pygame.cdrom.get_count()
cd_object.init()
cd_object.eject()
class ForkingServer(ForkingMixIn, SimpleXMLRPCServer):
pass
serveraddr = ('', 8765)
srvr = ForkingServer(serveraddr, SimpleXMLRPCRequestHandler)
srvr.register_instance(Math())
srvr.register_introspection_functions()
srvr.serve_forever()
Code: Select all
import xmlrpclib, code
url = 'http://localhost:8765/'
s = xmlrpclib.ServerProxy(url)
interp = code.InteractiveConsole({'s': s})
interp.interact("Use s to interact with the App")
Traceback (most recent call last):
File "<console>", line 1, in ?
File "F:\Python24\lib\xmlrpclib.py", line 1096, in __call__
return self.__send(self.__name, args)
File "F:\Python24\lib\xmlrpclib.py", line 1383, in __request
verbose=self.__verbose
File "F:\Python24\lib\xmlrpclib.py", line 1137, in request
headers
ProtocolError: <ProtocolError for localhost:8765/: -1 >
ANy Ideas cheers