Feature #12077
openConsolidate SSLSocket interface with TCPSocket
Description
Hello,
Is there a reason why SSLSocket#read
doesn't work the same as SSLSocket#sysread
and why there is no SSLSocket#recv
?
Right now it is impossible to have code agnostic in regards to the socket type.
One solution is to monkey-patch OpenSSL::SSL::SSLSocket
(see lower) to share the same interface as TCPSocket
, but given the generic names of monkey-patched functions, I'm not sure if they could result with some leaks or strange behavior.
class OpenSSL::SSL::SSLSocket
def read(*args)
sysread(*args)
end
def write(*args)
syswrite(*args)
end
def close
sysclose
end
end
Thoughts?
Updated by tonci (Tonči Damjanić) almost 9 years ago
- Description updated (diff)
Updated by tonci (Tonči Damjanić) almost 9 years ago
- Description updated (diff)
Updated by tonci (Tonči Damjanić) over 8 years ago
- Assignee set to core
Updated by normalperson (Eric Wong) over 8 years ago
tonci.damjanic@gmail.com wrote:
Is there a reason why
SSLSocket#read
doesn't work the same
asSSLSocket#sysread
Because IO#read and IO#sysread are different, too. The former
is read-in-full behavior (outside of EOF) while sysread matches
the low-level C interface and allows for partial reads.
Likewise with write vs syswrite regarding write-in-full
behavior.
and why there is no
SSLSocket#recv
?
Currently, OpenSSL does not provide an interface to recv(2)
which handles flag arguments :<
I too wish for recv(2) and send(2) interfaces which lets me
use MSG_MORE|MSG_DONTWAIT flags.
Updated by naruse (Yui NARUSE) over 7 years ago
- Is duplicate of Feature #8126: OpenSSL::SSL::SSLSocket does not define #recv and #send messages added