Time service
The time service is a very basic example of RPyC services: it allows clients to query the server for the current time.
Service
import time import rpyc class TimeService(rpyc.Service): def exposed_gettime(self): return time.time()
Server
from rpyc.utils.server import ThreadedServer s = ThreadedServer(TimeService) s.start()
Client
import rpyc c = rpyc.connect_by_service("TIME") print "server's time is", c.root.gettime()
Note: the client requires the registry server be running somewhere on your local network (or anywhere else we can broadcast to). The registry server, like DNS, resolves a service name ("TIME" in this case) into an endpoint (host and port) we can establish a connection to.
page_revision: 10, last_edited: 1227297164|%e %b %Y, %H:%M %Z (%O ago)







