Table of Contents

Class IP

Internet protocol (IP) support functions such as DNS resolution.

Inheritance
IP

Remarks

IP contains support functions for the Internet Protocol (IP). TCP/IP support is in different classes (see StreamPeerTCP and TCPServer). IP provides DNS hostname resolution support, both blocking and threaded.

Fields

RESOLVER_MAX_QUERIES

Maximum number of concurrent DNS resolver queries allowed, RESOLVER_INVALID_ID is returned if exceeded.

const RESOLVER_MAX_QUERIES = 256

RESOLVER_INVALID_ID

Invalid ID constant. Returned if RESOLVER_MAX_QUERIES is exceeded.

const RESOLVER_INVALID_ID = -1

Methods

clear_cache(String)

Removes all of a hostname's cached references. If no hostname is given, all cached IP addresses are removed.

void clear_cache(String hostname)

Parameters

hostname String

erase_resolve_item(int)

Removes a given item id from the queue. This should be used to free a queue after it has completed to enable more queries to happen.

void erase_resolve_item(int id)

Parameters

id int

get_local_addresses

Qualifiers: const

Returns all the user's current IPv4 and IPv6 addresses as an array.

PackedStringArray get_local_addresses

get_local_interfaces

Qualifiers: const

Returns all network adapters as an array.

Each adapter is a dictionary of the form:

{
    "index": "1", # Interface index.
    "name": "eth0", # Interface name.
    "friendly": "Ethernet One", # A friendly name (might be empty).
    "addresses": ["192.168.1.101"], # An array of IP addresses associated to this interface.

}

Dictionary[] get_local_interfaces

get_resolve_item_address(int)

Qualifiers: const

Returns a queued hostname's IP address, given its queue id. Returns an empty string on error or if resolution hasn't happened yet (see IP.get_resolve_item_status).

String get_resolve_item_address(int id)

Parameters

id int

get_resolve_item_addresses(int)

Qualifiers: const

Returns resolved addresses, or an empty array if an error happened or resolution didn't happen yet (see IP.get_resolve_item_status).

Array get_resolve_item_addresses(int id)

Parameters

id int

get_resolve_item_status(int)

Qualifiers: const

Returns a queued hostname's status as a ResolverStatus constant, given its queue id.

int get_resolve_item_status(int id)

Parameters

id int

resolve_hostname(String, int)

Returns a given hostname's IPv4 or IPv6 address when resolved (blocking-type method). The address type returned depends on the Type constant given as ip_type.

String resolve_hostname(String host, int ip_type)

Parameters

host String
ip_type int

resolve_hostname_addresses(String, int)

Resolves a given hostname in a blocking way. Addresses are returned as an Array of IPv4 or IPv6 addresses depending on ip_type.

PackedStringArray resolve_hostname_addresses(String host, int ip_type)

Parameters

host String
ip_type int

resolve_hostname_queue_item(String, int)

Creates a queue item to resolve a hostname to an IPv4 or IPv6 address depending on the Type constant given as ip_type. Returns the queue ID if successful, or RESOLVER_INVALID_ID on error.

int resolve_hostname_queue_item(String host, int ip_type)

Parameters

host String
ip_type int