Network-related utilities and helper functions.
Returns the actual ipv4 of the local machine.
This code figures out what source address would be used if some traffic were to be sent out to some well known address on the Internet. In this case, IP from RFC5737 is used, but the specific address does not matter much. No traffic is actually sent.
Verify that address represents a valid IP address.
Parameters: | address (string) – Value to verify |
---|---|
Returns: | bool |
Verify that address represents a valid IPv4 address.
Parameters: | address (string) – Value to verify |
---|---|
Returns: | bool |
Verify that address represents a valid IPv6 address.
Parameters: | address (string) – Value to verify |
---|---|
Returns: | bool |
Verify that port represents a valid port number.
Interpret a string as a host:port pair.
An IPv6 address MUST be escaped if accompanied by a port, because otherwise ambiguity ensues: 2001:db8:85a3::8a2e:370:7334 means both [2001:db8:85a3::8a2e:370:7334] and [2001:db8:85a3::8a2e:370]:7334.
>>> parse_host_port('server01:80')
('server01', 80)
>>> parse_host_port('server01')
('server01', None)
>>> parse_host_port('server01', default_port=1234)
('server01', 1234)
>>> parse_host_port('[::1]:80')
('::1', 80)
>>> parse_host_port('[::1]')
('::1', None)
>>> parse_host_port('[::1]', default_port=1234)
('::1', 1234)
>>> parse_host_port('2001:db8:85a3::8a2e:370:7334', default_port=1234)
('2001:db8:85a3::8a2e:370:7334', 1234)
>>> parse_host_port(None)
(None, None)
Set values for tcp keepalive parameters
This function configures tcp keepalive parameters if users wish to do so.
Parameters: |
|
---|