Class IP
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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.
public static class IP
- Inheritance
-
IP
- Inherited Members
Fields
ResolverInvalidId
Invalid ID constant. Returned if ResolverMaxQueries is exceeded.
public const long ResolverInvalidId = -1
Field Value
ResolverMaxQueries
Maximum number of concurrent DNS resolver queries allowed, ResolverInvalidId is returned if exceeded.
public const long ResolverMaxQueries = 256
Field Value
Properties
Singleton
public static IPInstance Singleton { get; }
Property Value
Methods
ClearCache(string)
Removes all of a hostname
's cached references. If no hostname
is given, all cached IP addresses are removed.
public static void ClearCache(string hostname = "")
Parameters
hostname
string
EraseResolveItem(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.
public static void EraseResolveItem(int id)
Parameters
id
int
GetLocalAddresses()
Returns all the user's current IPv4 and IPv6 addresses as an array.
public static string[] GetLocalAddresses()
Returns
- string[]
GetLocalInterfaces()
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.
}
public static Array<Dictionary> GetLocalInterfaces()
Returns
GetResolveItemAddress(int)
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 GetResolveItemStatus(int)).
public static string GetResolveItemAddress(int id)
Parameters
id
int
Returns
GetResolveItemAddresses(int)
Returns resolved addresses, or an empty array if an error happened or resolution didn't happen yet (see GetResolveItemStatus(int)).
public static Array GetResolveItemAddresses(int id)
Parameters
id
int
Returns
GetResolveItemStatus(int)
Returns a queued hostname's status as a IP.ResolverStatus constant, given its queue id
.
public static IP.ResolverStatus GetResolveItemStatus(int id)
Parameters
id
int
Returns
ResolveHostname(string, Type)
Returns a given hostname's IPv4 or IPv6 address when resolved (blocking-type method). The address type returned depends on the IP.Type constant given as iPType
.
public static string ResolveHostname(string host, IP.Type iPType = Type.Any)
Parameters
Returns
ResolveHostnameAddresses(string, Type)
Resolves a given hostname in a blocking way. Addresses are returned as an Array of IPv4 or IPv6 addresses depending on iPType
.
public static string[] ResolveHostnameAddresses(string host, IP.Type iPType = Type.Any)
Parameters
Returns
- string[]
ResolveHostnameQueueItem(string, Type)
Creates a queue item to resolve a hostname to an IPv4 or IPv6 address depending on the IP.Type constant given as iPType
. Returns the queue ID if successful, or ResolverInvalidId on error.
public static int ResolveHostnameQueueItem(string host, IP.Type iPType = Type.Any)