Пример #1
0
def host2(listen_port, remote_port):
    s = Streamer(dst_ip="localhost", dst_port=remote_port,
                 src_ip="localhost", src_port=listen_port)
    # send small pieces of data
    for i in range(NUMS):
        buf = ("%d " % i)
        print("sending {%s}" % buf)
        s.send(buf.encode('utf-8'))
    receive(s)
    s.close()
    print("STAGE 2 TEST PASSED!")
Пример #2
0
def host1(listen_port, remote_port):
    s = Streamer(dst_ip="localhost", dst_port=remote_port,
                 src_ip="localhost", src_port=listen_port)
    receive(s)
    print("STAGE 1 TEST PASSED!")
    # send large chunks of data
    i = 0
    buf = ""
    while i < NUMS:
        buf += ("%d " % i)
        if len(buf) > 12345 or i == NUMS-1:
            print("sending {%s}" % buf)
            s.send(buf.encode('utf-8'))
            buf = ""
        i += 1
    s.close()
    print("CHECK THE OTHER SCRIPT FOR STAGE 2 RESULTS.")