I am doing an assignment for a class and need a little help trying to understand how to get started on this assignment. This is needing to be program in python and any help is greatly appreciated.
Distributed Computing with XML-RPC
Description
Common tasks in distributed computing applications often require the ability of one computer to be able to remotely invoke a procedure on another computer in the distributed system. This assignment introduces this idea further using XML-RPC and Python.
XML-RPC is a protocol used to call procedures, (i.e. methods or functions) by one computer (client) on another computer (server). Its name results from fact that XML is used to encode the procedure calls. The means used to transport the XML from the client to the server is HTTP. While Python has built-in support for this functionality, it is important to note that support is not limited to Python but extends to most high level languagesadd. This is inherent in the design since the encoding is generic XML and transport is HTTP.
Finally, there are many ways to implement such functionality. For Python, while outside the scope of this course, the interested reader should explore projects such as Pyro, RPyC, and Fabric.
XML-RPC's implementation in Python is found in the xmlrpc package. In this package, the required modules are xmlrpc.client and xmlrpc.server.
Assignment
This assignment requires you to develop two Python programs. One is a client, the other is the server.
Server
The server should "register" x procedures that the client will be able to call. It will then bind to the address "localhost" and port 8000. This is the address and port that the server will listen to for requests. Note that if you have binding errors, you may use another port as your computer may have an application that is using 8000. Most of the time, however, this will work. Your server invocation must be in the following form:
python server.py localhost 8000
These procedures to be supported are as follows:
name - returns the name of the server which is passed on the commandline during server invocation
help - returns a list of procedures that the server supports
servertime - returns the current time at the server in 24 hour format. I.e. 13:00:01
add(x,y) - returns the sum of x and y
sub(x,y) - returns x - y
mult(x,y) - returns x * y
div(x,y) - returns x/y (be sure to handle the divid by 0 scenario)
Client
The client is to connect to the server using the server's address and the port that the server is listening on (see above). It then will exercise each of the supported procedures using the values 8 and 6 for the values x and y respectively. Your client invocation must be in the following form:
python client.py host_address host_port 8 6
where host_address and host_port are the address and port that the server is listening on. If you are using a single computer for server and client computers just use "localhost" for the address and the port used above. The 8 and the 6 are the values for x and y.
Example Output Of Client:
8 * 6 is 48.0
8 / 6 is 1.3333333333333333
8 + 6 is 14.0
8 - 6 is 2.0
8 / 0 is Infinity
13:50:22
Server.py
#importing sys module
#importing time module
#importing xmlrpc module
import sys import time from xmlrpc.server import SimpleXMLRPCServer #sys.argv returns a list of command-line arguments as strings argumentlist = sys.argv #storing 1st argument ie hostname. 0th argument would be filename host_address = argumentlist[1] #storing 2nd argument ie port no port = argumentlist[2] #SimpleXMLRPCServer class create a new server instance server = SimpleXMLRPCServer((host_address,int(port))) #methods you want to implement at server side def addition(x,y): return x + y def subtraction(x,y): return x - y def multiplication(x,y): return x * y def division(x,y): try: return x/y except: return "Infinity" def name(): return host_address def help(): return server.system_listMethods() def servertime(): return time.strftime('%H:%M:%S') #server.register_function(function=None,name=None) register a function that can respond to XML-RPC requests #params # function parameter is name of the you implemented at server side # name parameter is name that you want to give to the function # server.register_function(addition, "add") server.register_function(subtraction, "sub") server.register_function(multiplication, "mul") server.register_function(division, "div") server.register_function(name, "name") server.register_function(help, "help") server.register_function(servertime, "servertime") #run the server's main loop which means server is continuosly running and listening to requests server.serve_forever()
exectuion command of server program at terminal: python Server.py localhost 8000
Client.py:
#importing xmlrpc module #importing sys module import xmlrpc.client import sys argumentslist = sys.argv #sys.argv returns a list of command-line arguments host_address = argumentslist[1] #storing 1st argument ie hostname. 0th argument would be filename host_port = argumentslist[2] #storing 2nd argument ie port no uri = "http://"+host_address+":"+host_port num1 = int(argumentslist[3]) #storing 3 argument which is a first num that we will pass to method num2 = int(argumentslist[4]) #storing 3 argument which is a first num that we will pass to method proxy = xmlrpc.client.ServerProxy(uri) #returns a server proxy object with which we can call methods #methods that client will call print('{} + {} is {}'.format(num1,num2,proxy.add(num1, num2))) print('{} - {} is {}'.format(num1,num2,proxy.sub(num1, num2))) print('{} * {} is {}'.format(num1,num2,proxy.mul(num1, num2))) print('{} / {} is {}'.format(num1,num2,proxy.div(num1, num2))) print(proxy.name()) #returns server's name print(proxy.help()) #returns list of available methods at server print(proxy.servertime()) #returns server's time in 24hrs format
client output:
I am doing an assignment for a class and need a little help trying to understand...
1. Which of the following protocols is used by a client to send an email message? a. HTTP SMTP b. FTP d. RDP 2. What is the most common network topology today? a/Star c. Hub Ring d. Mesh 3. A client/server network is the simplest network model. a/ True O False 4. Which client server application allows an administrator to control a remote computer, but does not encrypt or secure the communication between client and server? A Telnet C. Remote...
Part - Web Server Setup and Demonstration (AJ Objective The objective of this assignment is to some HTTP as application layer protocol and TCP as reliable transport layer protocol HTTP is carried by TCP. Also, in the assignment you will investigate the working of client-server mechanism from both application and networking perspective There are several different ways to setup an HTTP server, including through Apache Tomcat, Apache Glassfish that integrales in an IDE such as Eclipse/NetBeans or even a browser...
*****Can someone please HELP me with this assignment please, I am struggling with this assignment and would appreciate some help, needs to be done in c/c++ ******* (100 marks) In this problem, you will write a file transfer program for transferring files between two computers connected by a network. The protocol that you will implement is called the Simple File Transfer Protocol (SFTP). The complete description for SFTP is given below. PART 1 SFTP is a simple protocol for transferring...
The way I understand it is i'm trying to link a list that I read into python from a cvs file to json and xml and pass the doctest. Please refere the lines where I show what I did below. home / study / engineering / computer science / questions and answers / """this script converts a csv file with headers ... Question: """This script converts a CSV file with headers to... Bookmark """This script converts a CSV file with...
Hi I need some help in C programing class and I doing one of the exercise so that I can get better at coding. Suppose you are asked to design a software that helps an elementary school student learn multiplication and division of one-digit integer numbers. The software allows the student to select the arithmetic operation she or he wishes to study. The student chooses from a menu one of two arithmetic operations: 1) Multiplication and 2) Division (quotient). Based...
on calculations can i see how did the expect come to the solution ,all the workout should be included QUESTION 1 A file of size F = 8 Gbits needs to be distributed to10 peers. Suppose the server has an upload rate of u = 68 Mbps, and that the 10 peers have upload rates of: u1 = 20 Mbps, u2 = 22 Mbps, u3 = 12 Mbps, u4 = 19 Mbps, u5 = 25 Mbps, u6 = 24 Mbps,...
?=55 completing the attached table using thr given topology IPV4 & IPV6 Default G/W IPV4 Network Interface IP Interface Device IPV6 GUP 10.20.232/27 2002:DB8:?:A::/64 Name N/A 10.20.2.33/27 G0/0 RI N/A 2002:DB8:?:A::1/64 IC-20.cr S0/0/0 DC) S0/0/1 G0/0 R2 SO/0/0 S0/0/1 G0/0 R3 S0/0/0 S0/0/1 Management SWI port Management SW2 port Management SW3 port FastEthernet0 PCO PC1 FastEthernet0 FastEthernet0 PC2 PC3 FastEthernet0 Web- FastEthernet0 Server ALogical Physical x 1569. y 213 X LAN-1 1020.?32/27 2002:DB8.?A:/64 SW-1 Web Server R1 WAN-2 1.1.2.4/30 2004...
I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n): lst = [] for i in range(1,n+1): val = float(input('Enter float '+str(i)+': ')) lst.append(val) return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...
OpenSooq Assignment - Software Engineer Given two strings input of printable text, a and b . let the edit distance between a and b is least number of operations needed to transform a to b, write php code that calculate edit distance using: 1. hamming distance that only have substitute operations (ex. substitute letter X with letter Y). 2. Levenshtein distance: that have 3 possible operators: insert, delete or substitution operations the function should consider all possibilities but should not...
I need help with doing these tasks for code composer Lab 3 - Branching, Push Button and LEDs-Reading Assignment in this lab, we are going to control a LED via a push button- using general purpose digital 10 for both input (button) and output (LED) on port 1 - using Code Composer Studio. Furthermore, we are going to use a branch instruction to create an IF-ELSE structure in assembly to determine if the LED should be lit up based on...