-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix wrong default address when binding sockets #13006
Conversation
Thanks for your contribution! Looks good 👍 About the error case: Currently you'll get an exception with message entry = TCPSocket.new(family: :unix)
entry.bind(1234) # SocketError: Failed to create socket: Protocol not supported I think that's what should happen after this patch as well. Now we could handle this case explicitly here, or just pass it through. An exception will be raise eventually. Note that directly interpolating the address and port is an optimization that avoids an intermediary string allocation. |
hey, thanks for the feedback! FWIW I just tested the example you sent and it still raises the exception you mention, because that one is triggered in the changes updated 😄 |
Please avoid force pushes to active PRs. Instead, just append changes as new commits. See https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md#making-good-pull-requests |
Removed unused variable assignment in the unix socket test.
Oh, I'm sorry for overwriting the history, should have caught that earlier when reading the contributing docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all good 👍
Although the `address_and_port` is not used in `system_bind`, I think it's important to display a correct error message, and so the IPv6 is enclosed in square brackets [1] in case the exception is triggered [1]: https://datatracker.ietf.org/doc/html/rfc2732#section-2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
I don't think the failures are related to this PR. One is from OAuth, and the other one to bind SSL server but from the stacktrace it doesn't seem to touch any of my changes. |
Hello! This is my first PR!
The following code would crash on my laptop:
With the stacktrace
Because it tries to resolve the address
::
when the Family is INET.I am unsure on raising an exception because that case should never hit since you cannot initiate an unix socket by only assigning a port, advice is welcomed!