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.start, cFunc.error)
- reactor.run()
- class Cfunc(pb.Referenceable):
- #start server and client waiting for input
- def start(self, objS1):
- objS1.callRemote('talks', self)
- #take input and print on client and server.
- def remote_talkc(self, objS1):
- #ask for input FROM SERVER (?)
- l = objS1.callRemote('listen')
- #when received, print
- l.addCallback(self.hear)
- #...and start the process over again...
- self.start(objS1)
- def remote_listen(self):
- message = raw_input('c: ')
- return message
- def hear(self, message):
- print "Client 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