pynetdicom.transport.AddressInformation#

class pynetdicom.transport.AddressInformation(addr: str, port: int, flowinfo: int = 0, scope_id: int = 0)[source]#

IPv4 or IPv6 address information.

Added in version 3.0.

port#

The port number.

Type:

int

flowinfo#

The flow info value (IPv6)

Type:

int

scope_id#

The scope ID (IPv6)

Type:

int

__init__(addr: str, port: int, flowinfo: int = 0, scope_id: int = 0) None[source]#

Create a new AddressInformation instance.

Parameters:
  • addr (str) – The IP address (IPv4 and IPv6).

  • port (int) – The port number (IPv4 and IPv6).

  • flowinfo (int, optional) – The flow info value (IPv6 only), default 0.

  • scope_id (int, optional) – The scope ID (IPv6 only), default 0.

Methods

__init__(addr, port[, flowinfo, scope_id])

Create a new AddressInformation instance.

from_addr_port(addr, port)

Return the a new AddressInformation instance from addr and port

from_tuple(address_info)

Return the a new AddressInformation instance from address_info

Attributes

address

Get or set the IP address.

address_family

Return the address family enum that the address belongs to.

as_tuple

Return the address information as (address, port) or (address, port, flowinfo, scope_id).

is_ipv4

Return True if the address belongs to the IPv4 family, False otherwise.

is_ipv6

Return True if the address belongs to the IPv6 family, False otherwise.

property address: str#

Get or set the IP address.

Parameters:

value (str) –

The IPv4 or IPv6 address. The following conversion will be made:

  • "" (INADDR_ANY) -> "0.0.0.0"

  • "<broadcast>" (INADDR_BROADCAST) -> "255.255.255.255"

  • "localhost" -> "127.0.0.1"

Returns:

The IPv4 or IPv6 address.

Return type:

str

property address_family: AddressFamily#

Return the address family enum that the address belongs to.

property as_tuple: tuple[str, int] | tuple[str, int, int, int]#

Return the address information as (address, port) or (address, port, flowinfo, scope_id).

classmethod from_addr_port(addr: str | tuple[str, int, int], port: int) AddressInformation[source]#

Return the a new AddressInformation instance from addr and port

Parameters:
  • addr (str | tuple[str, int, int]) –

    One of the following:

    • str: an IPv4 or IPv6 address. If the latter then the flowinfo and scope_id will be set to 0

    • tuple[str, int, int]: an IPv6 address as (address, flowinfo, scope_id)

  • port (int) – The port number.

classmethod from_tuple(address_info: tuple[str, int] | tuple[str, int, int, int]) AddressInformation[source]#

Return the a new AddressInformation instance from address_info

Parameters:

address_info (tuple[str, int] | tuple[str, int, int, int]) –

One of the following:

  • tuple[str, int]: an IPv4 or IPv6 address and port. If the latter then the flowinfo and scope_id will be set to 0

  • tuple[str, int, int, int]: an IPv6 address as (address, port, flowinfo, scope_id)

property is_ipv4: bool#

Return True if the address belongs to the IPv4 family, False otherwise.

property is_ipv6: bool#

Return True if the address belongs to the IPv6 family, False otherwise.