resolve_sync


Description:

public uint resolve_sync (Cancellable? cancellable = null)

Synchronously resolves the missing half of this, as with resolve_async.

If cancellable is non-%NULL, it can be used to cancel the resolution. resolve_sync will then return a status of CANCELLED.

It is safe to call this more than once, even from different threads, but it is not safe to mix calls to resolve_sync with calls to resolve_async on the same address.

Example: Resolve an address, sync:

public static int main (string[] args) {
Cancellable cancellable = new Cancellable ();
// Use cancellable.cancel () to abort the resolution

Soup.Address address = new Soup.Address ("www.gnome.org", 80);
uint status = address.resolve_sync (cancellable);

switch (status) {
case Soup.Status.OK:
print ("Resolved! %s\n", address.get_physical ());
break;

case Soup.Status.CANT_RESOLVE:
print ("Error: Unable to resolve destination host name.\n");
break;

case Soup.Status.CANCELLED:
print ("Error: Message was cancelled locally.\n");
break;

default:
assert_not_reached ();
}

return 0;
}

valac --pkg libsoup-2.4 message-resolve-sync.vala

Parameters:

this

a Address

cancellable

a Cancellable object, or null

Returns:

OK, CANT_RESOLVE, or CANCELLED.