-
Notifications
You must be signed in to change notification settings - Fork 35
Fix documentation #55
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ def getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0): | |
def gethostbyname(hostname): | ||
"""Translate a host name to IPv4 address format. The IPv4 address | ||
is returned as a string. | ||
|
||
:param str hostname: Desired hostname. | ||
""" | ||
addr = _the_interface.get_host_by_name(hostname) | ||
|
@@ -73,6 +74,7 @@ def gethostbyname(hostname): | |
|
||
def is_ipv4(host): | ||
"""Checks if a host string is an IPv4 address. | ||
|
||
:param str host: host's name or ip | ||
""" | ||
octets = host.split(".", 3) | ||
|
@@ -88,9 +90,9 @@ def is_ipv4(host): | |
class socket: | ||
"""A simplified implementation of the Python 'socket' class | ||
for connecting to a Wiznet5k module. | ||
|
||
:param int family: Socket address (and protocol) family. | ||
:param int type: Socket type. | ||
|
||
""" | ||
|
||
# pylint: disable=redefined-builtin,unused-argument | ||
|
@@ -162,8 +164,8 @@ def getpeername(self): | |
|
||
def inet_aton(self, ip_string): | ||
"""Convert an IPv4 address from dotted-quad string format. | ||
:param str ip_string: IP Address, as a dotted-quad string. | ||
|
||
:param str ip_string: IP Address, as a dotted-quad string. | ||
""" | ||
self._buffer = b"" | ||
self._buffer = [int(item) for item in ip_string.split(".")] | ||
|
@@ -173,6 +175,7 @@ def inet_aton(self, ip_string): | |
def bind(self, address): | ||
"""Bind the socket to the listen port, if host is specified the interface | ||
will be reconfigured to that IP. | ||
|
||
:param tuple address: local socket as a (host, port) tuple. | ||
""" | ||
if address[0] is not None: | ||
|
@@ -191,6 +194,7 @@ def bind(self, address): | |
|
||
def listen(self, backlog=None): | ||
"""Listen on the port specified by bind. | ||
|
||
:param backlog: For compatibility but ignored. | ||
""" | ||
assert self._listen_port is not None, "Use bind to set the port before listen!" | ||
|
@@ -228,6 +232,7 @@ def accept(self): | |
|
||
def connect(self, address, conntype=None): | ||
"""Connect to a remote socket at address. | ||
|
||
:param tuple address: Remote socket as a (host, port) tuple. | ||
""" | ||
assert ( | ||
|
@@ -253,6 +258,7 @@ def connect(self, address, conntype=None): | |
def send(self, data): | ||
"""Send data to the socket. The socket must be connected to | ||
a remote socket. | ||
|
||
:param bytearray data: Desired data to send to the socket. | ||
""" | ||
_the_interface.socket_write(self.socknum, data, self._timeout) | ||
|
@@ -261,6 +267,7 @@ def send(self, data): | |
def sendto(self, data, address): | ||
"""Send data to the socket. The socket must be connected to | ||
a remote socket. | ||
|
||
:param bytearray data: Desired data to send to the socket. | ||
:param tuple address: Remote socket as a (host, port) tuple. | ||
""" | ||
|
@@ -269,6 +276,7 @@ def sendto(self, data, address): | |
|
||
def recv(self, bufsize=0, flags=0): # pylint: disable=too-many-branches | ||
"""Reads some bytes from the connected remote address. | ||
|
||
:param int bufsize: Maximum number of bytes to receive. | ||
:param int flags: ignored, present for compatibility. | ||
""" | ||
|
@@ -327,9 +335,10 @@ def recv(self, bufsize=0, flags=0): # pylint: disable=too-many-branches | |
|
||
def recvfrom(self, bufsize=0, flags=0): | ||
"""Reads some bytes from the connected remote address. | ||
|
||
:param int bufsize: Maximum number of bytes to receive. | ||
:param int flags: ignored, present for compatibility. | ||
:returns: a tuple (bytes, address) where address is a tuple (ip, port) | ||
:return: a tuple (bytes, address) where address is a tuple (ip, port) | ||
""" | ||
return ( | ||
self.recv(bufsize), | ||
|
@@ -341,10 +350,11 @@ def recvfrom(self, bufsize=0, flags=0): | |
|
||
def recv_into(self, buf, nbytes=0, flags=0): | ||
"""Reads some bytes from the connected remote address info the provided buffer. | ||
|
||
:param bytearray buf: Data buffer | ||
:param nbytes: Maximum number of bytes to receive | ||
:param int flags: ignored, present for compatibility. | ||
:returns: the number of bytes received | ||
:return: the number of bytes received | ||
""" | ||
if nbytes == 0: | ||
nbytes = len(buf) | ||
|
@@ -355,10 +365,11 @@ def recv_into(self, buf, nbytes=0, flags=0): | |
|
||
def recvfrom_into(self, buf, nbytes=0, flags=0): | ||
"""Reads some bytes from the connected remote address info the provided buffer. | ||
|
||
:param bytearray buf: Data buffer | ||
:param nbytes: Maximum number of bytes to receive | ||
:param int flags: ignored, present for compatibility. | ||
:returns a tuple (nbytes, address) where address is a tuple (ip, port) | ||
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 believe this should be |
||
:return: a tuple (nbytes, address) where address is a tuple (ip, port) | ||
""" | ||
return ( | ||
self.recv_into(buf, nbytes), | ||
|
@@ -371,7 +382,6 @@ def recvfrom_into(self, buf, nbytes=0, flags=0): | |
def readline(self): | ||
"""Attempt to return as many bytes as we can up to \ | ||
but not including '\r\n'. | ||
|
||
""" | ||
stamp = time.monotonic() | ||
while b"\r\n" not in self._buffer: | ||
|
@@ -407,8 +417,8 @@ def available(self): | |
|
||
def settimeout(self, value): | ||
"""Sets socket read timeout. | ||
:param int value: Socket read timeout, in seconds. | ||
|
||
:param int value: Socket read timeout, in seconds. | ||
""" | ||
if value < 0: | ||
raise Exception("Timeout period should be non-negative.") | ||
|
@@ -417,6 +427,5 @@ def settimeout(self, value): | |
def gettimeout(self): | ||
"""Return the timeout in seconds (float) associated | ||
with socket operations, or None if no timeout is set. | ||
|
||
""" | ||
return self._timeout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice catch!