diff options
| author | UltraQbik <no1skill@yandex.ru> | 2024-08-22 04:45:39 +0300 |
|---|---|---|
| committer | UltraQbik <no1skill@yandex.ru> | 2024-08-22 04:45:39 +0300 |
| commit | 9a539001f3f1e77a6ea8332f659695d7ddcedb2f (patch) | |
| tree | b26ba03bda05a5584f384e18317d380cffcbf178 /src/socks.py | |
| parent | 4f741ce90cd857aba53de06047b9221fa27b0c61 (diff) | |
| download | httpy-9a539001f3f1e77a6ea8332f659695d7ddcedb2f.tar.gz httpy-9a539001f3f1e77a6ea8332f659695d7ddcedb2f.zip | |
Massive refactoring addition of API
Diffstat (limited to 'src/socks.py')
| -rw-r--r-- | src/socks.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/socks.py b/src/socks.py new file mode 100644 index 0000000..119a62a --- /dev/null +++ b/src/socks.py @@ -0,0 +1,20 @@ +import time +from ssl import SSLSocket + + +async def ssl_sock_accept(sock: SSLSocket) -> tuple[SSLSocket, str]: + while True: + try: + return sock.accept() + except BlockingIOError: + time.sleep(1.e-3) + + +async def ssl_sock_recv(sock: SSLSocket, buflen: int = 1024): + while (msg := sock.recv(buflen)) == b'': + time.sleep(1.e-3) + return msg + + +async def ssl_sock_sendall(sock: SSLSocket, data: bytes): + sock.sendall(data) |