SocketAddressEnumerator


Object Hierarchy:

GLib.SocketAddressEnumerator GLib.SocketAddressEnumerator GLib.SocketAddressEnumerator GLib.Object GLib.Object GLib.Object->GLib.SocketAddressEnumerator

Description:

[ CCode ( type_id = "g_socket_address_enumerator_get_type ()" ) ]
public abstract class SocketAddressEnumerator : Object

`GSocketAddressEnumerator` is an enumerator type for [class@Gio.

SocketAddress] instances. It is returned by enumeration functions such as [method@Gio.SocketConnectable.enumerate], which returns a `GSocketAddressEnumerator` to list each [class@Gio.SocketAddress] which could be used to connect to that [iface@Gio.SocketConnectable].

Enumeration is typically a blocking operation, so the asynchronous methods [method@Gio.SocketAddressEnumerator.next_async] and [ method@Gio.SocketAddressEnumerator.next_finish] should be used where possible.

Each `GSocketAddressEnumerator` can only be enumerated once. Once [method@Gio.SocketAddressEnumerator.next] has returned `NULL`, further enumeration with that `GSocketAddressEnumerator` is not possible, and it can be unreffed.

Example: SocketAddressEnumerator:

public static void example_sync () {
InetAddress address = new InetAddress.from_string ("208.80.152.201");
InetSocketAddress socket_address = new InetSocketAddress (address, 80);

try {
SocketAddressEnumerator en = socket_address.enumerate ();
for (SocketAddress add = en.next (); add != null; add = en.next ()) {
print ("%s\n", add.get_family ().to_string ());
}
} catch (Error e) {
print ("Error: %s\n", e.message);
}
}

public async void example_async () {
InetAddress address = new InetAddress.from_string ("208.80.152.201");
InetSocketAddress socket_address = new InetSocketAddress (address, 80);

try {
SocketAddressEnumerator en = socket_address.enumerate ();
for (SocketAddress add = yield en.next_async (); add != null; add = yield en.next_async ()) {
print ("%s\n", add.get_family ().to_string ());
}
} catch (Error e) {
print ("Error: %s\n", e.message);
}
}

public static int main (string[] args) {
// Output: ``G_SOCKET_FAMILY_IPV4`` (15. Nov. 2012)
example_sync ();

// Output: ``G_SOCKET_FAMILY_IPV4`` (15. Nov. 2012)
MainLoop loop = new MainLoop ();
example_async.begin ((obj, res) => {
loop.quit ();
});
loop.run ();
return 0;
}

valac --pkg gio-2.0 GLib.SocketAddressEnumerator.vala

All known sub-classes:

Namespace: GLib
Package: gio-2.0

Content:

Creation methods:

Methods:

Inherited Members: