fhttpy/modules/helpers.py

15 lines
300 B
Python
Raw Normal View History

2022-02-14 21:43:12 +00:00
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