Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates > by-pkgid > 8e2794c56d40434f013b2f4bb2904b31 > files > 295

python-foolscap-0.5.1-1.fc13.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()