Skip to content

SSLSocket#accept is confusing. #760

@ioquatix

Description

@ioquatix

I would like to propose that we rename SSLSocket#accept and SSLSocket#accept_nonblock to SSLSocket#start and SSLSocket#start_nonblock.

There are two reasons:

  1. It aligns better with SSLServer#start_immediately. In other words, start_immediately -> call SSLSocket#start immediately on accept.
  2. It avoids confusion with Socket#accept (and indirectly SSLServer#accept) which serve an entirely different purpose.

I tried to write generic socket handling code like this:

server.accept do |socket|
  if socket.respond_to?(:accept)
    socket.accept
  end
  
  yield socket
end

However this code failed because Socket implements #accept - I did not think the design through fully. But, I think overloading SSLSocket#accept in this way is basically confusing.

Of course, we should keep aliases for backwards compatibility.

@rhenium wdyt?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions