Project

General

Profile

Feature #12077

Consolidate SSLSocket interface with TCPSocket

Added by tonci (Tonči Damjanić) over 1 year ago. Updated about 1 year ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:73840]

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?


Related issues

Duplicates Ruby trunk - Bug #8126: OpenSSL::SSL::SSLSocket does not define #recv and #send messages Open

History

#1 [ruby-core:73841] Updated by tonci (Tonči Damjanić) over 1 year ago

  • Description updated (diff)

#2 [ruby-core:73842] Updated by tonci (Tonči Damjanić) over 1 year ago

  • Description updated (diff)

#3 [ruby-core:73963] Updated by tonci (Tonči Damjanić) about 1 year ago

  • Assignee set to ruby-core

#4 [ruby-core:74175] Updated by normalperson (Eric Wong) about 1 year ago

tonci.damjanic@gmail.com wrote:

Is there a reason why SSLSocket#read doesn't work the same
as SSLSocket#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.

#5 Updated by naruse (Yui NARUSE) about 1 year ago

  • Assignee deleted (ruby-core)

#6 Updated by naruse (Yui NARUSE) 28 days ago

  • Duplicates Bug #8126: OpenSSL::SSL::SSLSocket does not define #recv and #send messages added

Also available in: Atom PDF