Sophie

Sophie

distrib > Mageia > 1 > i586 > by-pkgid > 22e60e8a385ab7f1c7f2eb7eb45c6aef > files > 197

python-foolscap-0.6.1-2.mga1.noarch.rpm

#! /usr/bin/python

from twisted.internet import reactor
from foolscap.api import Referenceable, UnauthenticatedTub

class MathServer(Referenceable):
    def remote_add(self, a, b):
        return a+b
    def remote_subtract(self, a, b):
        return a-b

myserver = MathServer()
tub = UnauthenticatedTub()
tub.listenOn("tcp:12345")
tub.setLocation("localhost:12345")
url = tub.registerReference(myserver, "math-service")
print "the object is available at:", url

tub.startService()
reactor.run()