diff options
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) |