Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python
- from twisted.spread import pb
- from twisted.internet import reactor
- def main():
- cFunc = Cfunc()
- f = pb.PBClientFactory()
- reactor.connectTCP("localhost", 1025, f) #open connection
- f.getRootObject().addCallbacks(cFunc.add, cFunc.error)
- reactor.run()
- class Cfunc(pb.Referenceable):
- def add(self, objS1):
- self.objS1 = objS1
- print "C: added server object address"
- objS1.callRemote("add", self).addCallbacks(self.talkc, self.error)
- def talkc(self):
- message = raw_input("c: ")
- self.objS1.callRemote("hear", message)
- self.talkc()
- print "C: sent message to remote server"
- def remote_hear(self, message):
- print "C Heard: "
- print message
- def error(self, reason):
- print "Remote exception: "
- print reason
- reactor.stop()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement