Пример #1
0
def echo_client():
    socket = Sock(N, N.net[1])
    s1 = socket.socket(AF_INET, SOCK_DGRAM)
    ip = ip_to_str(0)
    r = randint(0, 256)
    print "t:", xtime.time(), ("sending data %d to " + ip) % (r)
    s1.sendto('hey ' + str(r), (ip, 51423))
    message, address = s1.recvfrom(8192)
    print "t:", xtime.time(), "got reply from %s: %s" % (address, message)
Пример #2
0
def echo_client():
    socket=Sock(N, N.net[1])
    s1=socket.socket(AF_INET, SOCK_DGRAM)
    ip = ip_to_str(0)
    r=randint(0, 256)
    print "t:", xtime.time(), ("sending data %d to "+ip)%(r)
    s1.sendto('hey '+str(r), (ip, 51423))
    message, address = s1.recvfrom(8192)
    print "t:", xtime.time(), "got reply from %s: %s"%(address, message)
Пример #3
0
def udp_client():
    client = rpc.BcastClient(devs=['lo'],
                             port=PORT,
                             net=N,
                             me=N.net[1],
                             sockmodgen=Sock)
    print xtime.time(), "calling void func"
    client.void_func()
    client.void_func_caller()
    print xtime.time(), "udp_client end"
Пример #4
0
def echo_client_II():
    socket = Sock(N, N.net[1])
    s1 = socket.socket(AF_INET, SOCK_DGRAM)
    ip = ip_to_str(0)

    r = randint(0, 256)
    print "t:", xtime.time(), ("II sending data %d to " + ip) % (r)
    s1.connect((ip, 51423))
    s1.send('hey ' + str(r))
    message = s1.recv(8192)
    print "t:", xtime.time(), "got reply from %s: %s" % (ip, message)
Пример #5
0
def echo_client_II():
    socket=Sock(N, N.net[1])
    s1=socket.socket(AF_INET, SOCK_DGRAM)
    ip = ip_to_str(0)

    r=randint(0, 256)
    print "t:", xtime.time(), ("II sending data %d to "+ip)%(r)
    s1.connect((ip, 51423))
    s1.send('hey '+str(r))
    message = s1.recv(8192)
    print "t:", xtime.time(), "got reply from %s: %s"%(ip, message)
Пример #6
0
def tcp_handler(conn, addr):
    print "t:", xtime.time(), "Got connection from", str(addr)
    while 1:
        try:
            #               message = conn.recv(1)
            message = conn.recv(8192)
            if not message: break
            print "t:", xtime.time(), "Got data message: %s" % message
            conn.send('ACK')
        except:
            traceback.print_exc()
            raise
    print "t:", xtime.time(), addr, "connection closed"
Пример #7
0
def tcp_handler(conn, addr):
    print "t:", xtime.time(),"Got connection from",str(addr)
    while 1:
        try:
#               message = conn.recv(1)
                message = conn.recv(8192)
                if not message: break
                print "t:", xtime.time(), "Got data message: %s"%message
                conn.send('ACK')
        except:
                traceback.print_exc()
                raise
    print "t:", xtime.time(), addr, "connection closed"
Пример #8
0
def tcp_echo_client():
    socket = Sock(N, N.net[1])
    s1 = socket.socket(AF_INET, SOCK_STREAM)
    ip = ip_to_str(0)
    print "t:", xtime.time(), "waiting"
    xtime.swait(70)
    print "t:", xtime.time(), "connecting to " + ip
    s1.connect((ip, 51423))

    r = randint(0, 256)
    s1.send('Hallo, ' + str(r))
    s1.send('How are you?')
    message = s1.recv(8192)
    print "t:", xtime.time(), "tcp server replied:", message
Пример #9
0
def tcp_echo_client():
    socket=Sock(N, N.net[1])
    s1=socket.socket(AF_INET, SOCK_STREAM)
    ip = ip_to_str(0)
    print "t:", xtime.time(), "waiting"
    xtime.swait(70)
    print "t:", xtime.time(), "connecting to "+ip
    s1.connect((ip, 51423))

    r=randint(0, 256)
    s1.send('Hallo, '+str(r))
    s1.send('How are you?')
    message = s1.recv(8192)
    print "t:", xtime.time(), "tcp server replied:", message
Пример #10
0
def tcp_client():
    client = rpc.TCPClient(ip_to_str(N.net[0].ip),
                           port=PORT,
                           net=N,
                           me=N.net[1],
                           sockmodgen=Sock)

    x = 5
    xsquare = client.square(x)
    print xtime.time(), 'assert xsquare == 25'
    assert xsquare == 25
    xmul7 = client.mul(x, 7)
    print xtime.time(), 'assert xmul7 == 35'
    assert xmul7 == 35
    xadd9 = client.nestmod.add(x, 9)
    print xtime.time(), 'assert xadd9 == 14'
    assert xadd9 == 14

    # something trickier
    n, nn = client, client.nestmod
    result = n.square(n.mul(x, nn.add(x, 10)))

    assert (1, 2) == client.caller_test(1, 2)

    try:
        # should crash now
        client.private_func()
    except Exception, e:
        logging.debug(str(e))
Пример #11
0
def tcp_client():
    client = rpc.TCPClient(ip_to_str(N.net[0].ip), port=PORT, net=N, me=N.net[1], sockmodgen=Sock)

    x = 5
    xsquare = client.square(x)
    print xtime.time(), "assert xsquare == 25"
    assert xsquare == 25
    xmul7 = client.mul(x, 7)
    print xtime.time(), "assert xmul7 == 35"
    assert xmul7 == 35
    xadd9 = client.nestmod.add(x, 9)
    print xtime.time(), "assert xadd9 == 14"
    assert xadd9 == 14

    # something trickier
    n, nn = client, client.nestmod
    result = n.square(n.mul(x, nn.add(x, 10)))

    assert (1, 2) == client.caller_test(1, 2)

    try:
        # should crash now
        client.private_func()
    except Exception, e:
        logging.debug(str(e))
Пример #12
0
def echo_srv():
    """Standard echo server example"""
    host = ''
    port = 51423
    socket=Sock(N, N.net[0])
    s0=socket.socket(AF_INET, SOCK_DGRAM)
    s0.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    s0.bind((host, port))
    while 1:
            try:
                message, address = s0.recvfrom(8192)
                print "t:", xtime.time(), "Got data from %s: %s"%(address, message)
                s0.sendto('yo there ('+message+')', address)
            except:
                traceback.print_exc()
Пример #13
0
def echo_srv():
    """Standard echo server example"""
    host = ''
    port = 51423
    socket = Sock(N, N.net[0])
    s0 = socket.socket(AF_INET, SOCK_DGRAM)
    s0.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    s0.bind((host, port))
    while 1:
        try:
            message, address = s0.recvfrom(8192)
            print "t:", xtime.time(), "Got data from %s: %s" % (address,
                                                                message)
            s0.sendto('yo there (' + message + ')', address)
        except:
            traceback.print_exc()
Пример #14
0
def myxtime():
    t = xtime.time()
    T.append(t)
    return t
Пример #15
0
def myxtime():
        t=xtime.time()
        T.append(t)
        return t
Пример #16
0
def udp_client():
    client = rpc.BcastClient(devs=["lo"], port=PORT, net=N, me=N.net[1], sockmodgen=Sock)
    print xtime.time(), "calling void func"
    client.void_func()
    client.void_func_caller()
    print xtime.time(), "udp_client end"