Index · Object → IP

IP

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

Class Description

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.

Methods

func clear_cache(hostname: String = "") -> void

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

func erase_resolve_item(id: int) -> void

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.

func get_local_addresses() -> PackedStringArray

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

func get_local_interfaces() -> Dictionary[]

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.
}
func get_resolve_item_address(id: int) -> String

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 get_resolve_item_status()).

func get_resolve_item_addresses(id: int) -> Array

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

func get_resolve_item_status(id: int) -> IP.ResolverStatus

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

func resolve_hostname(host: String, ip_type: IP.Type = 3) -> String

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.

func resolve_hostname_addresses(host: String, ip_type: IP.Type = 3) -> PackedStringArray

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

func resolve_hostname_queue_item(host: String, ip_type: IP.Type = 3) -> 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.

Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)

Enums & Constants

enum ResolverStatus
RESOLVER_STATUS_NONE = 0

DNS hostname resolver status: No status.

RESOLVER_STATUS_WAITING = 1

DNS hostname resolver status: Waiting.

RESOLVER_STATUS_DONE = 2

DNS hostname resolver status: Done.

RESOLVER_STATUS_ERROR = 3

DNS hostname resolver status: Error.

enum Type
TYPE_NONE = 0

Address type: None.

TYPE_IPV4 = 1

Address type: Internet protocol version 4 (IPv4).

TYPE_IPV6 = 2

Address type: Internet protocol version 6 (IPv6).

TYPE_ANY = 3

Address type: Any.

const RESOLVER_MAX_QUERIES = 256

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

const RESOLVER_INVALID_ID = -1

Invalid ID constant. Returned if RESOLVER_MAX_QUERIES is exceeded.