module documentation

Utility functions for network aspects.

Function getIPAddress Lookup and return the IP address for a host name.
Function isTCPPortAvailable Check whether a TCP port is available.
Function isValidateHostname Validate a host name.
Function isValidateIpAddress Validate an IP address.
Function isValidPort Validate a port number.
Function isValidURL Validate a URL.
Function pingTCPServer Ping a TCP server on a specific port.
Variable _allowedPart Regular expression for validating host names.
def getIPAddress(hostname: str | None = None) -> str:

Lookup and return the IP address for a host name.

Parameters
hostname:str | NoneThe host name to look-up. If none is given, the own host name is tried.
Returns
strIP address, or 127.0.0.1 as a last resort. None is returned in case of an error.
def isTCPPortAvailable(port: int) -> bool:

Check whether a TCP port is available.

Parameters
port:intThe port to check.
Returns
boolTrue if port is available, or False otherwise.
def isValidateHostname(hostname: str) -> bool:

Validate a host name.

Parameters
hostname:strThe host name to validate.
Returns
boolTrue if the hostname is valid, or False otherwise.
def isValidateIpAddress(ip: str) -> bool:

Validate an IP address.

Parameters
ip:strThe IP address to validate.
Returns
boolTrue or False.
def isValidPort(port: str | int) -> bool:

Validate a port number.

Parameters
port:str | intThe port number to validate.
Returns
boolTrue if port is valid, or False otherwise.
def isValidURL(url: str) -> bool:

Validate a URL.

Parameters
url:strThe URL to validate.
Returns
boolTrue if url is valid, or False otherwise.
def pingTCPServer(server: str, port: int, timeout: float = 3.0) -> bool:

Ping a TCP server on a specific port.

Parameters
server:strThe server to ping.
port:intThe port to ping.
timeout:floatThe timeout in seconds.
Returns
boolTrue or False
_allowedPart =

Regular expression for validating host names.