-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSLSocket#accept
is confusing.
#760
Comments
I think
This feels like a wrong abstraction to me. I suppose the |
I think an unfortunate design choice here is that However, I'm worried changing a fundamental interface now will cause another kind of confusion. |
For background, the current model of performing The correct strategy as you may already know is something like this: server.start_immediately = false
server.accept do |socket|
Thread.new do
if socket.respond_to?(:accept)
socket.accept
end
yield socket
end
end Trying to solve this problem in a way which merges these two operations is thus not a solution.
Can't they? Is it not possible to call |
Yes, a naive implementation like A simplistic implementation that just delays the handshake, like Since
It is. But before calling # We currently have this
s = SSLSocket.new(tcp, tx) # SSL_new()
s.accept # SSL_accept() (== SSL_set_accept_state() + SSL_do_handshake())
# a possible alternative interface we could have opted for
s = SSLSocket.server(tcp, ctx) # SSL_new() + SSL_set_accept_state()
s.start # SSL_do_handshake()
# but if we have both -- it's an error to do this. Isn't it confusing?
s = SSLSocket.new(tcp, tx) # SSL_new()
s.start # SSL_do_handshake() |
I basically disagree, and think it's worth renaming and/or adding an alias. I think it's extremely confusing and as I already stated it can be dangerous. Expecting users to use |
I would like to propose that we rename
SSLSocket#accept
andSSLSocket#accept_nonblock
toSSLSocket#start
andSSLSocket#start_nonblock
.There are two reasons:
SSLServer#start_immediately
. In other words,start_immediately
-> callSSLSocket#start
immediately on accept.Socket#accept
(and indirectlySSLServer#accept
) which serve an entirely different purpose.I tried to write generic socket handling code like this:
However this code failed because
Socket
implements#accept
- I did not think the design through fully. But, I think overloadingSSLSocket#accept
in this way is basically confusing.Of course, we should keep aliases for backwards compatibility.
@rhenium wdyt?
The text was updated successfully, but these errors were encountered: