Skip to content
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

Add SSLSocket.open as alias of SSLSocket.new #225

Closed
ioquatix opened this issue Oct 9, 2018 · 1 comment
Closed

Add SSLSocket.open as alias of SSLSocket.new #225

ioquatix opened this issue Oct 9, 2018 · 1 comment
Milestone

Comments

@ioquatix
Copy link
Member

ioquatix commented Oct 9, 2018

TCPSocket.open is a thing, but there is no equivalent to SSLSocket.open.

This becomes a tricky problem to work around, often requiring overloading in #initialize to handle the different cases. The main cases are:

Make a new socket and connect to this hostname (should be .open).

Make a new socket with the given file descriptor or some other specific situation (should be .new).

This issue becomes a problem when making wrappers. Because in your own #initialize you need to detect the intent of the user. I'm not sure if there is an alternative or not.

socketry/async-io#13

So, ideally, we simply add an alias SSLSocket.open is identical to SSLSocket.new. But, for the purposes such as HTTP.rb, we expect that to use socket_class.open rather than socket_class.new.

@ioquatix
Copy link
Member Author

ioquatix commented Oct 9, 2018

For more details see socketry/async-io#12 which shows why this is a problem, specifically the implicit implementation of #initialize which has to handle both the "public interface" of SSLSocket as well as the internal wrapper state.

@ioquatix ioquatix added this to the v2.2.0 milestone Oct 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant