peng3dnet.util
- Utility functions¶
-
peng3dnet.util.
normalize_addr_formatted
(addr)[source]¶ Normalizes the given address to a string like
127.0.0.1
.This method is currently not implemented.
-
peng3dnet.util.
normalize_addr_socketstyle
(addr, default_port=8080)[source]¶ Normalizes the given address to a 2-tuple as accepted by the
socket
module.Currently accepts a 2-tuple and IPv4 addresses in string format.
If the address does not contain a port, the
default_port
will be used.Note that this function will pass through any exceptions raised by parsing functions it calls.
-
peng3dnet.util.
parse_address
(addr, default_port=8080)[source]¶ Parses an IP Address into a tuple of
(addr,port)
.If the address does not contain an explicitly specified port, the value given with
default_port
is used.Note that currently only IPv4 addresses are supported, but IPv6 support may be added in the future. If an IPv6 Address is detected, a
UnsupportedAddressError
will be raised.Additionally, the port returned is checked for plausibility, e.g. an integer in range 0-65535. If the port is invalid in any way, a
InvalidPortError
will be raised.