-
Notifications
You must be signed in to change notification settings - Fork 74
Reorg code per request from orphan pr 69 #107
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -52,14 +52,23 @@ class socket: | |||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
# pylint: disable=too-many-arguments | ||||||||||||||||||||||||||||||||
def __init__( | ||||||||||||||||||||||||||||||||
self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None, socknum=None | ||||||||||||||||||||||||||||||||
self, | ||||||||||||||||||||||||||||||||
family=AF_INET, | ||||||||||||||||||||||||||||||||
type=SOCK_STREAM, | ||||||||||||||||||||||||||||||||
proto=0, | ||||||||||||||||||||||||||||||||
fileno=None, | ||||||||||||||||||||||||||||||||
socknum=None, | ||||||||||||||||||||||||||||||||
remote_ip=None, | ||||||||||||||||||||||||||||||||
remote_port=None, | ||||||||||||||||||||||||||||||||
Comment on lines
+61
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh that makes sense @tannewt! I will work on these changes as soon as I get a second and will test and push an update. Thank you again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No rush and no problem! Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tannewt I have implemented the changes. I wanted ask specifically how you would like this tested. Here is the result in the REPL. I obviously cant call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd imagine you need to create a socket and connect before calling it. The new requests library can work with CPython sockets so that's probably the best place to start. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tannewt I created an access point called Any suggestions on how to better check the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You actually need to connect a TCP socket and then call .getpeername() on it. The error is because you are calling it on the class, not an instance, and therefore no Why are you adding this overall? It doesn't seem like you have a use for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great question @tannewt. Over a year ago when I did the original PR I had issues where I had the device set up as an Access Point and if I accidently logged in from multiple browsers on various machines it would crash. This original PR was designed to check for that remote IP and if it was not 192.168.4.2 then don't connect. It was to add the ability to get this information if a developer wanted to implement functionality such as this. I am ok with closing the PR however. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what I tried to do originally as well. I can't seem to even create a socket object here.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the current ESP32-SPI implementation you need to call I could see this PR being helpful but if no one is using it enough to test, then we could just close for now. |
||||||||||||||||||||||||||||||||
): | ||||||||||||||||||||||||||||||||
if family != AF_INET: | ||||||||||||||||||||||||||||||||
raise RuntimeError("Only AF_INET family supported") | ||||||||||||||||||||||||||||||||
if type != SOCK_STREAM: | ||||||||||||||||||||||||||||||||
raise RuntimeError("Only SOCK_STREAM type supported") | ||||||||||||||||||||||||||||||||
self._buffer = b"" | ||||||||||||||||||||||||||||||||
self._socknum = socknum if socknum else _the_interface.get_socket() | ||||||||||||||||||||||||||||||||
self._remote_ip = remote_ip | ||||||||||||||||||||||||||||||||
self._remote_port = remote_port | ||||||||||||||||||||||||||||||||
Comment on lines
+70
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||
self.settimeout(0) | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
# pylint: enable=too-many-arguments | ||||||||||||||||||||||||||||||||
|
@@ -193,6 +202,16 @@ def socknum(self): | |||||||||||||||||||||||||||||||
"""The socket number""" | ||||||||||||||||||||||||||||||||
return self._socknum | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@property | ||||||||||||||||||||||||||||||||
def remote_ip(self): | ||||||||||||||||||||||||||||||||
"""The remote ip""" | ||||||||||||||||||||||||||||||||
return self._remote_ip | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@property | ||||||||||||||||||||||||||||||||
def remote_port(self): | ||||||||||||||||||||||||||||||||
"""The remote port""" | ||||||||||||||||||||||||||||||||
return self._remote_port | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+205
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||
def close(self): | ||||||||||||||||||||||||||||||||
"""Close the socket, after reading whatever remains""" | ||||||||||||||||||||||||||||||||
_the_interface.socket_close(self._socknum) | ||||||||||||||||||||||||||||||||
|
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.