Пример #1
0
def listener2():
    s = NitroSocket()
    s.connect("tcp://127.0.0.1:4444")
    s.sub("fool")

    print 'two!'

    while True:
        fr = s.recv()
        print fr.data
Пример #2
0
def listener():
    print 'one!'
    s = NitroSocket()
    s.connect("tcp://127.0.0.1:4444")
    s.sub("foo")

    print 'one!'

    while True:
        fr = s.recv()
        print fr.data
Пример #3
0
def sender(uniq):
    global done
    s = NitroSocket()
    s.connect("tcp://127.0.0.1:4445")

    for x in xrange(100000):
        fr = NitroFrame(uniq + str(x))
        s.send(fr)
        fr = s.recv()
        assert(fr.data == "mega" + uniq + str(x))

    print uniq, "done!"
    done += 1
Пример #4
0
    global done
    s = NitroSocket()
    s.connect("tcp://127.0.0.1:4445")

    for x in xrange(100000):
        fr = NitroFrame(uniq + str(x))
        s.send(fr)
        fr = s.recv()
        assert(fr.data == "mega" + uniq + str(x))

    print uniq, "done!"
    done += 1

proxy_sock_f = NitroSocket()
proxy_sock_b = NitroSocket()
proxy_sock_f.bind("tcp://127.0.0.1:4445")
proxy_sock_b.connect("tcp://127.0.0.1:4444")

thread.start_new_thread(backend, ())
sleep(0.5)
thread.start_new_thread(proxy_down, (proxy_sock_f, proxy_sock_b))
thread.start_new_thread(proxy_up, (proxy_sock_f, proxy_sock_b))
sleep(0.5)
map(lambda id: thread.start_new_thread(sender, (id,)),
    ["dog", "cat", "mouse", "rat"])

while done < 4:
    sleep(0.2)

print ".. All finished"