QUERY · ISSUE
ussl.wrap_socket: option for pre-allocated buffer
Problem Description
Wrapping a socket requires ~16kB of RAM.
When memory is heavily fragmented, wrapping a socket will fail:
>>> secure_socket = ussl.wrap_socket(...)
MemoryError: memory allocation failed, allocating 16725 bytes
Proposed Solution
Instead, it could be possible to pre-allocate the memory (early in runtime), and share that with the wrapped socket... for example:
buf = bytearray(16725)
secure_socket = ussl.wrap_socket(..., buf=buf)
CANDIDATE · ISSUE
unix: SSL client socket, exists unexpectedly upon wrap_sockets().
Running a unix port:
MicroPython v1.8.5-62-g964fb24-dirty on 2016-10-31; linux version
The following code throws me back to my terminal without any messages, a quick look suggest that mp_stream_posix_read doesn't return.
import usocket
import ussl
s = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
ss = ussl.wrap_socket(s)
Wrapping with server_size=True however, works as expected.