-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Expose local_address and remote_address. #63
Conversation
Pull Request Test Coverage Report for Build 44
💛 - Coveralls |
1 similar comment
Pull Request Test Coverage Report for Build 44
💛 - Coveralls |
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.
Thank you. Would you please add a test?
Is there any argument to be made for just exposing the socket object proper?
It would make more sense to expose the stream object than to expose the socket object. There isn't always a socket, but there is always a stream. And the stream is useful in other circumstances too, e.g. There's also python-trio/trio#280, which is about giving Note that when we do add this API to |
Maybe the way forward then is to expose the stream, require the user for now to access |
Making I'd much prefer the public API to have read-only properties like remote address, local address, or SSL certificate. If somebody really needs to manipulate the stream, they can either access the private attribute |
""" | ||
Local address of the connection. This is a ``(host, port)`` tuple. | ||
""" | ||
return self._stream.socket.getsockname() |
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.
I like this PR but a few requests:
- Not all streams have a
socket
, and we shouldn't leak an AttributeError. ReturningNone
seems reasonable. - There is a
ListenPort
class in this file that combines an IP address and a port number and exposes them in a nice little object. Maybe we can reuse that here if it is renamed to something likeSocketInfo
or something like that. - Please add test coverage.
Also,
This is addressed in #109. |
No description provided.