Beispiel #1
0
from rdt2_0 import RDTSocket
import time

server_addr = ("127.0.0.1", 9090)
server = RDTSocket()

if __name__ == '__main__':
    server.bind(server_addr)
    conn, addr = server.accept()

    while True:
        msg = conn.recv(1024)
        print(msg)
        if msg == b'0':
            break

    server.close()
    conn.close()
    print("Program exit!")
Beispiel #2
0
from rdt2_0 import RDTSocket
import time

if __name__ == '__main__':
    server = RDTSocket()
    server.bind(('127.0.0.1', 9999))

    while True:
        conn, client_addr = server.accept()
        start = time.perf_counter()
        while True:
            data = conn.recv(2048)
            if data:
                conn.send(data)
            else:
                break
        '''
        make sure the following is reachable
        '''
        conn.close()
        print(f'connection finished in {time.perf_counter()-start}s')