from rdt2_0 import RDTSocket from threading import * import time client_addr = ("127.0.0.1", 9092) client = RDTSocket() if __name__ == '__main__': client.bind(client_addr) client.connect(("127.0.0.1", 9090)) start = time.time() with open("../src/补充说明.pdf", 'rb') as file: data = file.read() client.send(data) with open("../dst/补充说明2.pdf", mode='wb') as file: data = client.recv(1024000000) print("-----------------------") print("Server Receive!", time.time() - start) print("-----------------------") file.write(data) client.close() print("Program exit!") # while True: # data = input(">") # client.send(data.encode()) # # if data == 'exit':
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')
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!")
from rdt2_0 import RDTSocket from socket import socket, AF_INET, SOCK_DGRAM, SOCK_STREAM import time if __name__ == '__main__': # server = RDTSocket() # server = socket(AF_INET, SOCK_STREAM) # check what python socket does server = RDTSocket(debug=True) # check what python socket does server.bind(('127.0.0.1', 33333)) # server.listen(0) # check what python socket does 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')