Author martin.panter
Recipients martin.panter
Date 2015-03-29.10:30:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The documentation claims that SSL socket objects provide some of the same methods as plain socket objects, including recv(), and that the “bufsize” parameter specifies the maximum amount of data to be received. With ordinary sockets, socket.recv(0) always seems to return zero bytes (b""), as expected. But not so with SSL sockets:

>>> import socket, ssl
>>> s = ssl.wrap_socket(socket.create_connection(("localhost", 631)))
>>> s.sendall(b"GET / HTTP/1.1\r\nHost: localhost\r\n\r\n")
>>> len(s.recv(0))
>>> len(s.recv(0))

The call will hang or raise SSLWantReadError when no data is actually available. Looking at the code, the value of zero seems to be used as a placeholder for a default of 1024 in Either the SSL module should be fixed to return no bytes (my preference), or the documentation needs to warn that the recv(0) is not supported, or does not work the same as for plain sockets. might also be affected.
Date User Action Args
2015-03-29 10:30:23martin.pantersetrecipients: + martin.panter
2015-03-29 10:30:23martin.pantersetmessageid: <>
2015-03-29 10:30:23martin.panterlinkissue23804 messages
2015-03-29 10:30:23martin.pantercreate