Пример #1
0
#!/usr/bin/python
# client.py - DMI - 8-11-03

# Usage: client [ <query> ]   (default query is "Hello world!")

import scop, sys

if len(sys.argv) > 1:
    query = sys.argv[1]
else:
    query = "Hello world!"
sock = scop.scop_open("localhost", "client")
reply = scop.scop_rpc(sock, "server", query)
print "Query <" + query + ">, Reply <" + reply + ">"
scop.scop_close(sock)
Пример #2
0
#!/usr/bin/python
# rtt_client.cpp - DMI - 8-11-03

# Usage: rtt_client [ <iterations> ]   (default is 1000)

import scop, sys, time

REPEATS = 1000

if len(sys.argv) == 2:
    REPEATS = int(sys.argv[1])
sock = scop.scop_open("localhost", "rtt_client")

tv_start = time.time()
for i in range(REPEATS):
    reply = scop.scop_rpc(sock, "server", "test")
    if reply != "tteesstt":
        print "Message error."
        sys.exit()
tv_end = time.time()

diff = tv_end - tv_start
print str(REPEATS) + " round trips in " + str(diff) + " seconds."
print "Time each = " + str(diff * 1000000 / REPEATS) + " us."
print str(REPEATS / diff) + " iterations per second."
scop.scop_close(sock)
Пример #3
0
#!/usr/bin/python
# xml_client.py - DMI - 11-11-03

# Usage: xml_client [<n> <k>]    (default values n = 4, k = 2)

import scop, sys

if len(sys.argv) != 3:
	n, k = 4, 2
else:
	n, k = int(sys.argv[1]), int(sys.argv[2])
sock = scop.scop_open("localhost", "xml_client")
v = [n, k]
w = scop.scop_rpc(sock, "xml_server", v)
print str(n) + " choose " + str(k) + " equals " + str(w) + "."
scop.scop_close(sock)
Пример #4
0
def faren_to_cent(sock, f):
	return scop.scop_rpc(sock, "method_server", f, "ftoc")
Пример #5
0
def cent_to_faren(sock, c):
	return scop.scop_rpc(sock, "method_server", c, "ctof")
Пример #6
0
def count_uses(sock):
	return scop.scop_rpc(sock, "method_server", None, "stats")