eval.py 1.01 KB
Newer Older
1
2
3
import sys
sys.path.insert(0, "./build")
import prrt
Andreas Schmidt's avatar
Andreas Schmidt committed
4
import time as time
5
6
7
8
9
10
11
12
13
14
15
import threading

class receiverThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.sock = prrt.PrrtSocket(5000, False)

    def run(self):
        print("Receiving")
        while(1):
            print("Recv")
Andreas Schmidt's avatar
Andreas Schmidt committed
16
17
18
19
20
            len, data = self.sock.recv()
            v = data[:len].decode('UTF-8')
            print(len, v)
            time.sleep(1)

21
22
23
24
25
26
27
28
29
30

        print("Receiver Thread")

class senderThread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.sock = prrt.PrrtSocket(6000, True)

    def run(self):
        print("Connecting")
Andreas Schmidt's avatar
Andreas Schmidt committed
31
        self.sock.connect("127.0.0.1", 5000)
32
        print("Connected")
Andreas Schmidt's avatar
Andreas Schmidt committed
33
34
35
36
37
        for i in range(10):
            self.sock.send("Test")
            time.sleep(0.001)

        self.sock.close();
38
39
40
41
42
43

if __name__ == "__main__":
    recvThread = receiverThread()
    sendThread = senderThread()

    recvThread.start()
Andreas Schmidt's avatar
Andreas Schmidt committed
44
    sendThread.start()