15 lines
300 B
Python
15 lines
300 B
Python
|
global time
|
||
|
import time
|
||
|
|
||
|
global recv
|
||
|
def recv(conn,l):
|
||
|
start = time.process_time()
|
||
|
timeo = conn.gettimeout()
|
||
|
bytes = b""
|
||
|
while l > 0:
|
||
|
b = conn.recv(l)
|
||
|
if b == b"": raise ConnectionResetError
|
||
|
if time.process_time() - start > timeo: raise TimeoutError
|
||
|
bytes += b
|
||
|
l -= len(b)
|
||
|
return bytes
|