Skip to content
Snippets Groups Projects
Commit c4ac876c authored by Dominique Marcadet's avatar Dominique Marcadet
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
import sys
import xmlrpc.client
random = xmlrpc.client.ServerProxy( 'http://localhost:8000' )
if __name__ == '__main__':
if len( sys.argv ) > 2:
random.setBounds( int( sys.argv[1] ), int( sys.argv[2] ))
else:
for i in range( 10 ):
print( random.nextRandom(), "", end='' )
print()
import random
from xmlrpc.server import SimpleXMLRPCServer
from xmlrpc.server import SimpleXMLRPCRequestHandler
# Restrict to a particular path.
class RequestHandler( SimpleXMLRPCRequestHandler ):
rpc_paths = ( '/RPC2', )
# Create server
with SimpleXMLRPCServer(( 'localhost', 8000 ),
requestHandler = RequestHandler,
allow_none = True ) as server:
class RandomServer:
min = 1
max = 100
def setBounds( self, min, max ):
if min <= max:
self.min = min
self.max = max
def nextRandom( self ):
return random.randint( self.min, self.max )
server.register_instance( RandomServer() )
server.serve_forever()
import os
os.system( 'python RandomClient.py' )
os.system( 'python RandomClient.py -2 2' )
os.system( 'python RandomClient.py' )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment